Example #1
0
TEST_F(BricksAudioMidiTest, VerifyTrackNames) {
	MidiReader reader(fileStream);
	for (int track = 0; !reader.EndOfFile(); reader.NextTrack(), track++) {
		while (!reader.EndOfTrack()) {
			AutoPointer<MidiEvent> event = reader.ReadEvent();
			if (event->GetType() == MidiEventType::TrackName && track > 0) // Track 0's track name is the MIDI file name
				EXPECT_EQ(String::Format("TRACK %d NAME", track), CastTo<MidiTextEvent>(event)->GetString()) << "Track name did not match";
		}
	}
}
Example #2
0
TEST_F(BricksAudioMidiTest, VerifyTrackNotes) {
	MidiReader reader(fileStream);
	for (int track = 0; !reader.EndOfFile(); reader.NextTrack(), track++) {
		int noteCount = 0;
		while (!reader.EndOfTrack()) {
			AutoPointer<MidiEvent> event = reader.ReadEvent();
			if (event->GetType() == MidiEventType::NoteOn) {
				EXPECT_EQ(track, CastTo<MidiNoteEvent>(event)->GetNote()) << "Track note value did not match";
				noteCount++;
			}
		}
		if (track > 0) // Track 0 has no notes, just tempo data
			EXPECT_EQ(4, noteCount) << "Unexpected note count";
	}
}