cpstmid — Get a MIDI note number (allows customized micro-tuning scales).
ifn -- function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios.
Init-rate only
cpsmid requires five parameters, the first, ifn, is the function table number of the tuning ratios, and the other parameters must be stored in the function table itself. The function table ifn should be generated by GEN02, with normalization inhibited. The first four values stored in this function are:
numgrades -- the number of grades of the micro-tuning scale
interval -- the frequency range covered before repeating the grade ratios, for example 2 for one octave, 1.5 for a fifth etc.
basefreq -- the base frequency of the scale in Hz
basekeymidi -- the MIDI note number to which basefreq is assigned unmodified
After these four values, the user can begin to insert the tuning ratios. For example, for a standard 12 note scale with the base frequency of 261 Hz assigned to the key number 60, the corresponding f-statement in the score to generate the table should be:
; numgrades interval basefreq basekeymidi tuning ratios (equal temp)
f1 0 64 -2 12 2 261 60 1 1.059463094359 1.122462048309 1.189207115003 ..etc...
Another example with a 24 note scale with a base frequency of 440 assigned to the key number 48, and a repetition interval of 1.5:
; numgrades interval basefreq basekeymidi tuning-ratios (equal temp)
f1 0 64 -2 24 1.5 440 48 1 1.01 1.02 1.03 ..etc...
Here is an example of the cpstmid opcode. It uses the file cpstmid.csd.
Example 152. Example of the cpstmid opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform -odac -M0 ;;;RT audio I/O with MIDI in ;-iadc ;;;uncomment -iadc if RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o cpstmid.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; after an example from Kevin Conder sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ; Table #1, a normal 12-tone equal temperament scale. ; numgrades = 12 (twelve tones) ; interval = 2 (one octave) ; basefreq = 261.659 (Middle C) ; basekeymidi = 60 (Middle C) gitemp ftgen 1, 0, 64, -2, 12, 2, 261.659, 60, 1.00, \ 1.059, 1.122, 1.189, 1.260, 1.335, 1.414, \ 1.498, 1.588, 1.682, 1.782, 1.888, 2.000 instr 1 ifn = 1 icps cpstmid ifn print icps asig oscil 0.6, icps, 2 outs asig, asig endin </CsInstruments> <CsScore> f 0 20 ;sine wave. f 2 0 16384 10 1 e </CsScore> </CsoundSynthesizer>