Hi, i'm trying to make a program that will scan each column of a guitar tab and play a note when it detects a number. I will do this by creating a char array and have the program scan each collumn of an int value. is this possible? if so, how do i do it?
A:
Create a for
or foreach
loop that goes through each array element. When the value of interest is found, you play the note.
JYelton
2010-06-04 16:37:16
A:
What will the array contain BESIDES integers? Blanks?
If nothing else, just use an int array to begin with, avoid casting from char. the "No Sound" value could be 0, or -1
But to loop through a 2D array, you would just use a nested for loop
for(int row = 0; rows > rowCount; row++)
{
for(int column = 0; column > columnCount; column ++)
{
note = yourArray[row][colum];
// do something with the note
}
}
Neil N
2010-06-04 16:37:28
He's doing chars because there's more than just integer possibilities. Other note styles (staccato, false harmonics, slide) will require values other than the typical integers for indicating fret location.
Jason M
2010-06-04 17:17:18
@Jason M: then ideally, he should be using an enum to handle all possible values.
Neil N
2010-06-04 17:36:05
the array contains dashes, like a guitar tab, a dash is a pause and a number is a note
2010-06-06 16:02:58
i'm done guys thanks for the help, the for loop worked. this makes a greatsummative project for grade 11 computer science, if someone want it i will send it to them
2010-06-20 21:28:20