Cabbage Logo
Back to Cabbage Site

How to convert an integer to cps

Hi,

sorry for my stupid request!

I added an integer value at notnum opcode; how convert the result in cps?
All the available csound opcodes takes at MIDI in, but I want to add one value to change it…

All that I found:

midinoteoncps - Gets a MIDI note number as a cycles-per-second frequency
midinoteonkey - Gets a MIDI note number value
midinoteonoct - Gets a MIDI note number value as octave-point-decimal value
midinoteonpch - Gets a MIDI note number as a pitch-class value

cps2pch — Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of the octave
cpsmidi — Get the note number of the current MIDI event, expressed in cycles-per-second
cpsmidib — Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in cycles-per-second
cpsmidinn - Converts a Midi note number value to cycles-per-second
cpsoct — Converts an octave-point-decimal value to cycles-per-second
cpspch — Converts a pitch-class value to cycles-per-second
cpstmid — Get a MIDI note number (allows customized micro-tuning scales).
cpstun — Returns micro-tuning values at k-rate
cpstuni — Returns micro-tuning values at init-rate
cpsxpch — Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of any interval

notnum — Get a note number from a MIDI event

pchbend — Get the current pitch-bend value for this channel
pchmidi — Get the note number of the current MIDI event, expressed in pitch-class units
pchmidib — Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in pitch-class units.
pchmidinn — Converts a Midi note number value to octave point pitch-class units.
pchoct — Converts an octave-point-decimal value to pitch-class.

octave — Calculates a factor to raise/lower a frequency by a given amount of octaves.
octcps — Converts a cycles-per-second value to octave-point-decimal.
octmidi — Get the note number, in octave-point-decimal units, of the current MIDI event.
octmidib — Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in octave-point-decimal.
octmidinn — Converts a Midi note number value to octave-point-decimal.
octpch — Converts a pitch-class value to octave-point-decimal.
(PS: many opcodes seems to double…)

someone help me, please…
many thank’s,
R

ipch notnum
ipch = ipch + 3

new Csound opcode:

intcps ival

ival can give min/max value = 0-127

with this opcode every integer value (in the range 0-127) is converted in cps facilitating the drafting of the code…

bad idea ?
R

Why not use cpsmidinn? It takes a value between 0 and 127 and return a frequency in cps? In the code below, iFreq should be 261.62.

iFreq cpsmidinn 60

Or maybe I missed something?

Hi Rory,

I would like to control via MIDI an oscillator, and in this case cpsmidinn is correct, but I would to add the value of the “Octave” knob:

take the MIDI note value, and add the value of the knob (±48, 4 Octaves Range) the result I would to convert in cps for oscili…

ipch notnum
ipch = ipch + iknob ; (iknob take the GUI value)

the cpsmidinn opcode CONTINUE to take the MIDI note value in cps WITHOUT the knob GUI value…
I do not understand how to do it…
R

This is exactly what you should do :smile: Just take the value from a GUI slider and add it to your MIDI note number? Let’s say your midi note number is iMidiFreq, then you would do something like this:

iTranspose chnget "transSlider"
iFreq cpsmidinn iMidiFreq+iTranpose

You see what I mean?

… I said it was a stupid request!!!

Many thanks for your support Rory!

R

Not stupid at all. That’s why I created this Csound specific forum.