static void PV_TestNoteOn(void) { BAESong song; BAEResult err; unsigned char i; song = BAESong_New(gMixer); if (song != NULL) { printf("Playing all notes (no instruments loaded):\n"); for (i=0; i<127; i++) { printf("%d,", i); // err = BAESong_ProgramBankChange(song, 0, i, 0, 0); err = BAESong_NoteOn(song, 0, i, 100, 0); if (err) { printf("Error: %s\n", BAEResultToStr(err)); } BAE_WaitMicroseconds(150000); } printf("Playing all notes (loading instruments):\n"); err = BAESong_ProgramBankChange(song, 0, 28, 0, 0); for (i=0; i<127; i++) { printf("%d,", i); // err = BAESong_ProgramBankChange(song, 0, i, 0, 0); // unsigned char channel, // unsigned char programNumber, // unsigned char bankNumber, // unsigned long time) if (err) { printf("Error: %s\n", BAEResultToStr(err)); } err = BAESong_NoteOnWithLoad(song, 0, i, 100, 0); // unsigned char channel, // unsigned char note, // unsigned char velocity, // unsigned long time) if (err) { printf("Error: %s\n", BAEResultToStr(err)); } BAE_WaitMicroseconds(200000); } BAESong_Delete(song); } else { FailedTest("Couldn't allocate BAESong object"); } }
// PlayRMF() // --------------------------------------------------------------------- // // BAEResult PlayRMF(BAEMixer theMixer, char *fileName) { BAEResult err; BAESong theSong = BAESong_New(theMixer); BAE_BOOL done; if (theSong) { err = BAESong_LoadRmfFromFile(theSong, (BAEPathName)fileName, 0, TRUE); if (err == BAE_NO_ERROR) { err = BAESong_Start(theSong, 0); if (err == BAE_NO_ERROR) { printf("BAE memory used for everything %ld\n\n", BAE_GetSizeOfMemoryUsed()); done = FALSE; while (done == FALSE) { BAESong_IsDone(theSong, &done); if (done == FALSE) { BAE_WaitMicroseconds(15000); } } BAE_WaitMicroseconds(900000); } else printf("playrmf: Couldn't start song (BAE Error #%d)\n", err); } else printf("playrmf: Couldn't open RMF file '%s' (BAE Error #%d)\n", fileName, err); } else { err = BAE_MEMORY_ERR; } BAESong_Delete(theSong); return err; }
// TestGetSetHardwareVolume() // --------------------------------------------- // // static BAEResult TestGetSetHardwareVolume(void) { BAEResult err; BAE_UNSIGNED_FIXED origVal, newVal; double f_in, f_out; err = BAEMixer_GetHardwareVolume(gMixer, &origVal); if (err) return err; for (f_in=-1.0; f_in<5.0; f_in+=.1) { err = BAEMixer_SetHardwareVolume(gMixer, FLOAT_TO_UNSIGNED_FIXED(f_in)); if (err) return err; err = BAEMixer_GetHardwareVolume(gMixer, &newVal); if (err) return err; f_out = UNSIGNED_FIXED_TO_FLOAT(newVal); printf("%g -> %g\n", f_in, f_out); if (f_in < 0) { if (f_out != 0) { FailedTest("Setting hardware volume to negative values should set to zero instead."); break; } } else if (f_in > 1) { if (f_out != 1) { FailedTest("Setting hardware volume to values >1.0 should set to 1.0 instead."); break; } } else { if ((f_in - f_out > .01) || (f_in - f_out < -.01)) { FailedTest("Difference between Set and Get values was not within tolerance."); break; } } BAE_WaitMicroseconds(200000); } err = BAEMixer_SetHardwareVolume(gMixer, origVal); // reset volume return err; }