Skip to main content
deleted 79 characters in body
Source Link

after another advice from user Blauelf my code looks like this: (I addedand compiles return noteHz to all of the if statements:) Thank you

still I do have the same control reaches... error

after another advice from user Blauelf my code looks like this: (I added return noteHz to all of the if statements)

still I do have the same control reaches... error

after another advice from user Blauelf my code looks like this: and compiles :) Thank you

added 2 characters in body
Source Link

after another advice from user Blauelf my code looks like this: (I added return noteHzreturn noteHz to all of the if statements)

after another advice from user Blauelf my code looks like this: (I added return noteHz to all of the if statements)

after another advice from user Blauelf my code looks like this: (I added return noteHz to all of the if statements)

after another advace still the same error
Source Link

EDIT 20.1.18

after another advice from user Blauelf my code looks like this: (I added return noteHz to all of the if statements)

int frequency(string note)
{

    int n = 0; // fraction(?) counter (n/12)
    int hz = 440; //Hz of A in the Octave
    int noteHz ;
    bool specialCase = false;
    float temp ;



    //2nd step: calculate the A hrtz of octave
    if (note[strlen(note) - 1] < 4)
    {
        for (int i = 1; 4 - i != strlen(note); i++)
            hz /= 2;
    }

    else if(note[strlen(note) - 1] > 4)
    {
        for (int j = 1; 4 + j != strlen(note); j++)
            hz *= 2;
    }

    else
        hz = 440;

   
    //1st step: check if we do have special representation of notes or "normal"


    if (note[1] == '#' && note[0] == 'B')//- this was my 1st code in this place this below (code with use of strncmp):
    {
        hz *=2;
        specialCase = true;
    }
    /*else*/ if (note[1] == 'b' && note[0] == 'A')
    n++;
    /*else*/ if (note[1] == '#')
    n++;
    /*else*/ if (note[1] == 'b')
    n--;
    else
    n += 0;

    if (specialCase)
    {
        n += 9;
        temp = pow(2, n/12);
        noteHz = hz / round(temp);
        return noteHz;
    }

    else if (note[0] == 'A')
        {
            noteHz = hz;
            return noteHz;
        }
    else if(note[0] == 'B' && specialCase == false)
        {
            n += 2;
            temp = pow(2, n/12);
            noteHz = hz * round(temp);
            return noteHz;
        }
    else if (note[0] == 'C')
        {
            n += 9;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'D')
        {
            n += 7;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'E')
        {
            n += 5;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'F')
        {
            n += 4;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }
    else if(note[0] == 'G')
        {
            n += 2;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }
    else
            return 0;

still I do have the same control reaches... error

EDIT 20.1.18

after another advice from user Blauelf my code looks like this: (I added return noteHz to all of the if statements)

int frequency(string note)
{

    int n = 0; // fraction(?) counter (n/12)
    int hz = 440; //Hz of A in the Octave
    int noteHz ;
    bool specialCase = false;
    float temp ;



    //2nd step: calculate the A hrtz of octave
    if (note[strlen(note) - 1] < 4)
    {
        for (int i = 1; 4 - i != strlen(note); i++)
            hz /= 2;
    }

    else if(note[strlen(note) - 1] > 4)
    {
        for (int j = 1; 4 + j != strlen(note); j++)
            hz *= 2;
    }

    else
        hz = 440;

   
    //1st step: check if we do have special representation of notes or "normal"


    if (note[1] == '#' && note[0] == 'B')//- this was my 1st code in this place this below (code with use of strncmp):
    {
        hz *=2;
        specialCase = true;
    }
    /*else*/ if (note[1] == 'b' && note[0] == 'A')
    n++;
    /*else*/ if (note[1] == '#')
    n++;
    /*else*/ if (note[1] == 'b')
    n--;
    else
    n += 0;

    if (specialCase)
    {
        n += 9;
        temp = pow(2, n/12);
        noteHz = hz / round(temp);
        return noteHz;
    }

    else if (note[0] == 'A')
        {
            noteHz = hz;
            return noteHz;
        }
    else if(note[0] == 'B' && specialCase == false)
        {
            n += 2;
            temp = pow(2, n/12);
            noteHz = hz * round(temp);
            return noteHz;
        }
    else if (note[0] == 'C')
        {
            n += 9;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'D')
        {
            n += 7;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'E')
        {
            n += 5;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }

    else if(note[0] == 'F')
        {
            n += 4;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }
    else if(note[0] == 'G')
        {
            n += 2;
            temp = pow(2, n/12);
            noteHz = hz / round(temp);
            return noteHz;
        }
    else
            return 0;

still I do have the same control reaches... error

changes after advice of user but still have the same error
Source Link
Loading
Source Link
Loading