Bear with me as I am relatively new to C.
I am trying to create a function, which could take the names of musical notes (i.e. D or D#) as an argument, and return the value of their corresponding midi note number (midi number table) with a second argument for octave.
However, I seem to be having problems with either the initialisation of the string, or using it within the function. This is the function I wrote:
int midi_number(char note[], int octave)
{
int midiNumber
if (note[1] = '#')
{
switch(note[0])
{
case 'C': case 'c':
midiNumber = 25;
break;
case 'D': case 'd':
midiNumber = 27;
break;
...
}
}
else
{
switch(note[0])
{
case 'C': case 'c':
midiNumber = 24;
break;
case 'D': case 'd':
midiNumber = 26;
break;
...
}
}
return (midiNumber + (octave * 12))
}
I am then calling the function as follows:
midi_number('C#', 1);
Hopefully this gets across the idea of what I'm trying to achieve. I have researched into pointers and arrays, but I can't see how it applies to what I am doing.
Any help massively appreciated!