次の関数 populateArpeggioArray は、いくつかのメンバーを含む typedef された構造体へのポインターを受け取ります。その ID は、私が抱えている問題に必ずしも関連しているとは限りません。populateArpeggioArray は、構造体へのポインターを関数 sortNoteStack に渡す前に、構造体の内部要素に対していくつかの操作を実行する必要があります。
私が見つけたのは、構造体が sortNoteStack によって操作されることはないということです。これは、populateArpeggioArray がある時点で、変更された値を sortNoteStack に渡す前に構造体へのポインターの値を変更するためです。
私が知る限り、コードは適切にフォーマットされているようで、構造体の要素に対して実行されるすべての操作に対して適切なポインター逆参照が行われます。私が見る限り、構造体へのポインターの値を変更できるコード行はありません。const プレフィックスを使用して構造体を宣言しても、そのメンバーも固定値にロックされるため、役に立ちません。
これはコードではなくシミュレーターの問題である可能性があるという考えにオープンですが、私が書いたコードに潜在的な問題がある場合は、私が間違っていることを理解したいと思います.
ご協力ありがとうございました。
-ニック
void populateArpeggioArray(arpeggio* arp) {
uint8_t i = 0,j=0, newNoteFlag=0;
for(i=0; i<12; i++) {
newNoteFlag = 0;
if(globals.keyboardCurrentState[i]) { /* Check to see if the current state shows that a keyboard button is pressed. */
arp->sequenceLength++; /* Temporarily increase the sequence length */
for(j=0;j < arp->sequenceLength;j++) { /* Check the pitch of each note currently in the note stack */
if(globals.keyboardNotes[i] == arp->notesUnordered[j].pitch) { /* If the currently selected note is already present in the note stack, */
arp->sequenceLength--;
newNoteFlag = 1; /* undo the temporary sequence length increase */
}
}
if(!newNoteFlag) {
arp->notesOrdered[arp->sequenceLength].pitch = globals.keyboardNotes[i]+liveArpeggio.transposeShift;
arp->notesUnordered[arp->sequenceLength].pitch = globals.keyboardNotes[i]+liveArpeggio.transposeShift; /* Add the new pitch to the appended note */
arp->notesOrdered[arp->sequenceLength].length = 111;
arp->notesUnordered[arp->sequenceLength].length = 111; /* Give the new note a default length. TEMP */
}
}
}
sortNoteStack(&arp);
}