.mid 파일의 노트 수를 계산하고 각 노트 수 (A ~ G #)를 출력 한 다음이를 파일로 출력하는 프로그램을 C++로 작성했습니다. 그것은 충분한 노트를 찾지 못한다. 그러나 나는 이유를 이해할 수 없다. midi.org의 MIDI 파일 문서를 기반으로 작성했습니다.MIDI 노트 계산 프로그램이 잘못된 결과 생성
파일을 읽는 동안 노트의 상태 바이트 인 1001nnnn을 찾은 다음 노트를 다음 바이트로 읽습니다. 나는 Anvil Studio를 사용하여 1 노트 만있는 MIDI 파일을 만들었고이 프로그램을 사용하여 분석 한 결과 1 노트 만 정확하다는 것을 알았지 만, 훨씬 더 큰 파일 (2000+ 노트)에 사용할 때 거의 모든 것을 찾을 수 없으며 때로는 노트의 90 % +가 하나 또는 두 개의 음정임을 알게됩니다.
메모를 검색하는 프로그램 세그먼트입니다. 이 파일은 ios :: binary로 바이트 모드로 열었습니다.
//Loop through every byte of the file
for (int i = 0; i <= size; i++) {
//Read next byte of file to tempblock
myfile.read(tempblock, 1);
//Put int value of byte in b
int b = tempblock[0];
//x = first 4 binary digits of b, appended with 0000
unsigned int x = b & 0xF0;
//If note is next, set the next empty space of notearray to the notes value, and then set notenext to 0
if (notenext) {
myfile.read(tempblock, 1);
int c = tempblock[0];
i++;
//Add the note to notearray if the velocity data byte is not set to 0
if (c != 0) {
notearray[notecount] = b;
notenext = 0;
notecount++;
}
}
//If note is not next, and x is 144 (int of 10010000, status byte for MIDI "Note on" message), set note next to true
else if (x == 144) {
notenext = 1;
}
}
무슨 일이 일어나는 지 아시나요? 파일 유형의 구성 요소가 누락되었거나 사용중인 파일에 문제가있을 수 있습니까? 주로 미디 리포지토리에서 다운로드 한 클래식 피아노 곡을보고 있습니다.
나는 0- 속력 노트를 다음과 같이 확인했습니다 : if (c! = 0) { notearray [notecount] = b; notenext = 0; notecount ++; } 피치 후 바이트는 속도가 –