pchtom

pchtom — Convert pch to midi note number

Description

Plugin opcode in emugens.

Convert pch to midi note number. pch representation has the form Octave.pitchclass, pitchclass being a number between 00 and 12.

                pch        midi    note name
                ----------------------------
                8.09       69      4A
                8.00       60      4C
          

Syntax

imidi pchtom ipch
kmidi pchtom kpch

Performance

kpch / ipch -- pitch represented as Octave.pitchclass

kmidi / imidi -- midi note number

[Note] Note

Use pchmidinn to perform the opposite operation of this opcode.

Examples

Here is an example of the pchtom opcode. It uses the file pchtom.csd.

Example 692. Example of the pchtom opcode.

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0

; Show some conversions, both at i- and at k-time

instr 1
  imidi = pchtom(8.09)
  print imidi

  kidx init 0
	
  kpch = 8 + kidx / 100
  kmidi = pchtom(kpch)
  kidx += 1
  printf "kpch: %f    kmidi: %f\n", kidx+1, kpch, kmidi

  if kidx >= 12 then
    turnoff
  endif

endin

</CsInstruments>
<CsScore>
i 1 0 1

</CsScore>
</CsoundSynthesizer>


See Also

pchoct, pchmidinn, cpsmidinn, ftom, mton

Credits

By: Eduardo Moguillansky 2017