I really don't know the best way to search for an answer so I am going to try to explain my problem.
I am writing a drum machine program and I have some parts in the code that I think could be made smaller. The biggest problem I have is that I don't know how to dynamically change an element in a function call.
For example I would like to change this:
Code:
hitFunc(void) {
wavPlay(sample0, vol, bal, etc);
wavPlay(sample1 vol, bal, etc);
wavPlay(sample2 vol, bal, etc);
wavPlay(sample3 vol, bal, etc);
wavPlay(sample4 vol, bal, etc);
wavPlay(sample5 vol, bal, etc);
wavPlay(sample6 vol, bal, etc);
//etc…
}
To something like this:
Code:
hitFunc(void) {
for(X=0; X < 16; X++) {
wavPlay(sampleX vol, bal, etc);
}
}
The issue I have is that sample0 is a structure of memory and I don’t know how to point it to sampleX where X is a variable number in a loop and have it work.
Any help would be appreciated!!!