//===========================================================================// // File: audhdw.thh // // Project: MUNGA Brick: Audio Manager // // Contents: Spec for audio manager // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 01/25/95 ECH Initial coding. // //---------------------------------------------------------------------------// // Copyright (C) 1994, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #include #include #define BUILD_NOISE_PHASE_TEST //#define BUILD_TONE_PHASE_TEST //#define BUILD_LOUDNESS_TEST //#define BUILD_CHAN_TEST //#define BUILD_SND_PLAY // //############################################################################# // TonePhaseTest //############################################################################# // class TonePhaseTest SIGNATURED { public: typedef enum { InPhase = 1, OutOfPhase, FrontSpeakers, RearSpeakers, StartTone, PrintMenu, StopCurrentTest } Command; TonePhaseTest(AudioHardware *audio_hardware); Logical TestInstance() const; void Run(); void DoCommand(Command command); AudioHardware *audioHardware; Command phaseCommand; Command positionCommand; short program; Logical runningTest; }; TonePhaseTest::TonePhaseTest(AudioHardware *audio_hardware) { Check(audio_hardware); audioHardware = audio_hardware; phaseCommand = InPhase; positionCommand = FrontSpeakers; program = 0; runningTest = False; } Logical TonePhaseTest::TestInstance() const { Check(audioHardware); return True; } void TonePhaseTest::Run() { Check(this); Logical quit_test = False; int input_char; // // Load SBKs // Check(audioHardware); audioHardware->GetFrontCard()->LoadSBK("tonephaz.sbk"); audioHardware->GetRearCard()->LoadSBK("tonephaz.sbk"); DoCommand(PrintMenu); while (!quit_test) { // // Get event from keyboard // if (kbhit()) { input_char = getch(); if (input_char == '' && !runningTest) { quit_test = True; continue; } else if (input_char == '' && runningTest) { DoCommand(StopCurrentTest); DoCommand(PrintMenu); } else { Command input_command = (Command)(input_char - '0'); if (input_command >= InPhase && input_command <= StartTone) { DoCommand(StopCurrentTest); DoCommand(input_command); } } } } } void TonePhaseTest::DoCommand(Command command) { Check(this); Logical start_test = False; // // Do the command // switch (command) { case InPhase: Tell("In Phase\n"); phaseCommand = InPhase; break; case OutOfPhase: Tell("Out Of Phase\n"); phaseCommand = OutOfPhase; break; case FrontSpeakers: Tell("Front speakers\n"); positionCommand = FrontSpeakers; break; case RearSpeakers: Tell("Rear speakers\n"); positionCommand = RearSpeakers; break; case StartTone: Tell("Start Tone\n"); if (phaseCommand == InPhase) program = 0; else program = 1; start_test = True; break; case PrintMenu: // // Print menu // Tell("\n"); Tell("<1> In Phase\n"); Tell("<2> Out Of Phase\n"); Tell("<3> Front speakers\n"); Tell("<4> Rear speakers\n"); Tell("<5> Start Tone\n"); Tell(" to end\n\n"); break; case StopCurrentTest: if (runningTest) { Tell("End current test\n"); if (positionCommand == FrontSpeakers) { audioHardware->GetFrontCard()->SendNoteOff(0, 60, 0); } else { audioHardware->GetRearCard()->SendNoteOff(0, 60, 0); } runningTest = False; } break; } if (start_test) { if (positionCommand == FrontSpeakers) { audioHardware->GetFrontCard()->SendController(0, 121, 1); // Reset audioHardware->GetFrontCard()->SendController(0, 0, 1); // Bank audioHardware->GetFrontCard()->SendController(0, 91, 0); // Reverb audioHardware->GetFrontCard()->SendController(0, 93, 0); // Chorus audioHardware->GetFrontCard()->SendProgramChange(0, program); audioHardware->GetFrontCard()->SendNoteOn(0, 60, 127); } else { audioHardware->GetRearCard()->SendController(0, 121, 1); // Reset audioHardware->GetRearCard()->SendController(0, 0, 1); // Bank audioHardware->GetRearCard()->SendController(0, 91, 0); // Reverb audioHardware->GetRearCard()->SendController(0, 93, 0); // Chorus audioHardware->GetRearCard()->SendProgramChange(0, program); audioHardware->GetRearCard()->SendNoteOn(0, 60, 127); } runningTest = True; } } // //############################################################################# // NoisePhaseTest //############################################################################# // class NoisePhaseTest SIGNATURED { public: typedef enum { InPhase = 1, OutOfPhase, FrontSpeakers, RearSpeakers, AllSpeakers, LowNoise, MidNoise, HighNoise, PrintMenu, StopCurrentTest } Command; NoisePhaseTest(AudioHardware *audio_hardware); Logical TestInstance() const; void Run(); void DoCommand(Command command); AudioHardware *audioHardware; Command phaseCommand; Command positionCommand; short program; Logical runningTest; }; NoisePhaseTest::NoisePhaseTest(AudioHardware *audio_hardware) { Check(audio_hardware); audioHardware = audio_hardware; phaseCommand = InPhase; positionCommand = FrontSpeakers; program = 0; runningTest = False; } Logical NoisePhaseTest::TestInstance() const { Check(audioHardware); return True; } void NoisePhaseTest::Run() { Check(this); Logical quit_test = False; int input_char; // // Load SBKs // Check(audioHardware); audioHardware->GetFrontCard()->LoadSBK("noizphaz.sbk"); audioHardware->GetRearCard()->LoadSBK("noizphaz.sbk"); DoCommand(PrintMenu); while (!quit_test) { // // Get event from keyboard // if (kbhit()) { input_char = getch(); if (input_char == '' && !runningTest) { quit_test = True; continue; } else if (input_char == '' && runningTest) { DoCommand(StopCurrentTest); DoCommand(PrintMenu); } else { Command input_command = (Command)(input_char - '0'); if (input_command >= InPhase && input_command <= HighNoise) { DoCommand(StopCurrentTest); DoCommand(input_command); } } } } } void NoisePhaseTest::DoCommand(Command command) { Check(this); Logical start_test = False; // // Do the command // switch (command) { case InPhase: Tell("In Phase\n"); phaseCommand = InPhase; break; case OutOfPhase: Tell("Out Of Phase\n"); phaseCommand = OutOfPhase; break; case FrontSpeakers: Tell("Front speakers\n"); positionCommand = FrontSpeakers; break; case RearSpeakers: Tell("Rear speakers\n"); positionCommand = RearSpeakers; break; case AllSpeakers: Tell("All speakers\n"); positionCommand = AllSpeakers; break; case LowNoise: Tell("Start Low noise\n"); if (phaseCommand == InPhase) program = 4; else program = 5; start_test = True; break; case MidNoise: Tell("Start Med noise\n"); if (phaseCommand == InPhase) program = 2; else program = 3; start_test = True; break; case HighNoise: Tell("Start High noise\n"); if (phaseCommand == InPhase) program = 0; else program = 1; start_test = True; break; case PrintMenu: // // Print menu // Tell("\n"); Tell("<1> In Phase\n"); Tell("<2> Out Of Phase\n"); Tell("<3> Front speakers\n"); Tell("<4> Rear speakers\n"); Tell("<5> All speakers\n"); Tell("<6> Start Low noise\n"); Tell("<7> Start Med noise\n"); Tell("<8> Start High noise\n"); Tell(" to end\n\n"); break; case StopCurrentTest: if (runningTest) { Tell("End current test\n"); if (positionCommand == FrontSpeakers || positionCommand == AllSpeakers) { audioHardware->GetFrontCard()->SendNoteOff(0, 60, 0); } if (positionCommand == RearSpeakers || positionCommand == AllSpeakers) { audioHardware->GetRearCard()->SendNoteOff(0, 60, 0); } runningTest = False; } break; } if (start_test) { if (positionCommand == FrontSpeakers || positionCommand == AllSpeakers) { audioHardware->GetFrontCard()->SendController(0, 121, 1); // Reset audioHardware->GetFrontCard()->SendController(0, 0, 1); // Bank audioHardware->GetFrontCard()->SendController(0, 91, 0); // Reverb audioHardware->GetFrontCard()->SendController(0, 93, 0); // Chorus audioHardware->GetFrontCard()->SendProgramChange(0, program); audioHardware->GetFrontCard()->SendNoteOn(0, 60, 127); } if (positionCommand == RearSpeakers || positionCommand == AllSpeakers) { audioHardware->GetRearCard()->SendController(0, 121, 1); // Reset audioHardware->GetRearCard()->SendController(0, 0, 1); // Bank audioHardware->GetRearCard()->SendController(0, 91, 0); // Reverb audioHardware->GetRearCard()->SendController(0, 93, 0); // Chorus audioHardware->GetRearCard()->SendProgramChange(0, program); audioHardware->GetRearCard()->SendNoteOn(0, 60, 127); } runningTest = True; } } // //############################################################################# // LoudnessTest //############################################################################# // #define AWE_VOL_ENV_VAR "AWE_MASTER_VOLUME" class LoudnessTest SIGNATURED { public: typedef enum { SetLevel = 1, PlayNoise, StopNoise, PrintMenu } Command; LoudnessTest(AudioHardware *audio_hardware); Logical TestInstance() const; void Run(); void DoCommand(Command command); AudioHardware *audioHardware; Command command; Logical runningTest; int currentVolume; }; LoudnessTest::LoudnessTest(AudioHardware *audio_hardware) { char *loudness_environment; if ((loudness_environment = getenv(AWE_VOL_ENV_VAR)) == NULL) currentVolume = 160; else currentVolume = atoi(loudness_environment); Check(audio_hardware); audioHardware = audio_hardware; command = PlayNoise; runningTest = False; } Logical LoudnessTest::TestInstance() const { Check(audioHardware); return True; } void LoudnessTest::Run() { Check(this); Logical quit_test = False; int input_char; // // Load SBKs // Check(audioHardware); audioHardware->GetFrontCard()->LoadSBK("loudness.sbk"); audioHardware->GetRearCard()->LoadSBK("loudness.sbk"); DoCommand(PrintMenu); DoCommand(PlayNoise); while (!quit_test) { // // Get event from keyboard // if (kbhit()) { input_char = getch(); if (input_char == '') { DoCommand(StopNoise); quit_test = True; } else { Command input_command = (Command)(input_char - '0'); if (input_command == SetLevel) { DoCommand(StopNoise); DoCommand(SetLevel); quit_test = True; } } } } } void LoudnessTest::DoCommand(Command command) { Check(this); // // Do the command // switch (command) { case PlayNoise: audioHardware->GetFrontCard()->SendController(0, 121, 1); // Reset audioHardware->GetFrontCard()->SendController(0, 0, 1); // Bank audioHardware->GetFrontCard()->SendController(0, 91, 0); // Reverb audioHardware->GetFrontCard()->SendController(0, 93, 0); // Chorus audioHardware->GetFrontCard()->SendProgramChange(0, 0); audioHardware->GetFrontCard()->SendNoteOn(0, 60, 127); audioHardware->GetRearCard()->SendController(0, 121, 1); // Reset audioHardware->GetRearCard()->SendController(0, 0, 1); // Bank audioHardware->GetRearCard()->SendController(0, 91, 0); // Reverb audioHardware->GetRearCard()->SendController(0, 93, 0); // Chorus audioHardware->GetRearCard()->SendProgramChange(0, 0); audioHardware->GetRearCard()->SendNoteOn(0, 60, 127); break; case StopNoise: audioHardware->GetFrontCard()->SendNoteOff(0, 60, 0); audioHardware->GetRearCard()->SendNoteOff(0, 60, 0); break; case SetLevel: { // // Read the specified input level // int input_level = -1; while (input_level < 0 || 255 < input_level) { Tell( "\nSet Level (0-255) (Current Level=" << currentVolume << "): " ); cin >> input_level; if (input_level < 0 || 255 < input_level) { Tell("Valid entries are 0 to 255.\n"); } } // // Write the bat file // ofstream output_file("setvol.bat", ios::out); Verify(output_file); output_file << "set " << AWE_VOL_ENV_VAR "=" << input_level << "\n"; } break; case PrintMenu: // // Print menu // Tell("\n"); Tell("Current Level=" << currentVolume << "\n"); Tell("\n"); Tell("<1> Set Level\n"); Tell(" to end\n\n"); break; } } // //############################################################################# // TestClass //############################################################################# // #define RAD360 (6.28318) Logical AudioHardware::TestClass() { AudioHardware audio_hardware; audio_hardware.Initialize(); // //-------------------------------------------------------------------------- // Noise Phase Test //-------------------------------------------------------------------------- // #if defined(BUILD_NOISE_PHASE_TEST) { NoisePhaseTest noise_phase_test(&audio_hardware); noise_phase_test.Run(); } #endif // //-------------------------------------------------------------------------- // Tone Phase Test //-------------------------------------------------------------------------- // #if defined(BUILD_TONE_PHASE_TEST) { TonePhaseTest tone_phase_test(&audio_hardware); tone_phase_test.Run(); } #endif // //-------------------------------------------------------------------------- // Loudness Test //-------------------------------------------------------------------------- // #if defined(BUILD_LOUDNESS_TEST) { LoudnessTest loudness_test(&audio_hardware); loudness_test.Run(); } #endif // //------------------------------------------------------------------ // Revised Speaker Channel Test //------------------------------------------------------------------ // #if defined(BUILD_CHAN_TEST) { clock_t end_time; MIDIValue channel; MIDIValue panValue; MIDIValue program; int speakSelect, front, rear, waitTime; speakSelect = 1; waitTime = 4; // // Load SBKs // audio_hardware.frontCard.LoadSBK("chantest.sbk"); audio_hardware.rearCard.LoadSBK("chantest.sbk"); // // Init channels // channel = 0; { // // Set to second bank // // Card 1 audio_hardware.frontCard.SendController(channel, 121, 1); // Reset audio_hardware.frontCard.SendController(channel, 0, 1); // Bank audio_hardware.frontCard.SendController(channel, 91, 0); // Reverb audio_hardware.frontCard.SendController(channel, 93, 0); // Chorus // Card 2 audio_hardware.rearCard.SendController(channel, 121, 1); // Reset audio_hardware.rearCard.SendController(channel, 0, 1); // Bank audio_hardware.rearCard.SendController(channel, 91, 0); // Reverb audio_hardware.rearCard.SendController(channel, 93, 0); // Chorus } // // Cycle through speaker channels // Tell("\n"); Tell("<1> rear-left\n"); Tell("<2> rear-center\n"); Tell("<3> rear-right\n"); Tell("<4> front & rear-left\n"); Tell("<5> front & rear-center\n"); Tell("<6> front & rear-right\n"); Tell("<7> front-left\n"); Tell("<8> front-center\n"); Tell("<9> front-right\n"); Tell(" to end\n\n"); while (speakSelect != -1) { switch (speakSelect){ case 1: front = 0; rear = 1; panValue = 0; Tell("Tones in rear-left\n"); break; case 2: front = 0; rear = 1; panValue = 63; Tell("Tones in rear-center\n"); break; case 3: front = 0; rear = 1; panValue = 127; Tell("Tones in rear-right\n"); break; case 4: front = 1; rear = 1; panValue = 0; Tell("Tones in front & rear-left\n"); break; case 5: front = 1; rear = 1; panValue = 63; Tell("Tones in front & rear-center\n"); break; case 6: front = 1; rear = 1; panValue = 127; Tell("Tones in front & rear-right\n"); break; case 7: front = 1; rear = 0; panValue = 0; Tell("Tones in front-left\n"); break; case 8: front = 1; rear = 0; panValue = 63; Tell("Tones in front-center\n"); break; case 9: front = 1; rear = 0; panValue = 127; Tell("Tones in front-right\n"); break; default: break; }; // Set Speaker Channel if (front){ //audio_hardware.frontCard.SendController(0, 121, 1); // Reset //audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 0); // Pgm audio_hardware.frontCard.SendController(0, 10, panValue); // Pan } if (rear) { //audio_hardware.rearCard.SendController(0, 121, 1); // Reset //audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 0); // Pgm audio_hardware.rearCard.SendController(0, 10, panValue); // Pan } // Play tones for (program = 0; program < 7; program++) { // // Set program // audio_hardware.frontCard.SendProgramChange(0, program); audio_hardware.rearCard.SendProgramChange(0, program); // // Play note // if (front) audio_hardware.frontCard.SendNoteOn(0, 60, 127); if (rear) audio_hardware.rearCard.SendNoteOn(0, 60, 127); end_time = clock() + waitTime*CLOCKS_PER_SEC; while (clock() < end_time) { } audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNoteOff(0, 60, 0); if (kbhit()) { switch (getch()){ case '': speakSelect = -1; break; case '1': speakSelect = 1; break; case '2': speakSelect = 2; break; case '3': speakSelect = 3; break; case '4': speakSelect = 4; break; case '5': speakSelect = 5; break; case '6': speakSelect = 6; break; case '7': speakSelect = 7; break; case '8': speakSelect = 8; break; case '9': speakSelect = 9; break; default: break; }; break; } } } } #endif // //------------------------------------------------------------------ // Sound Play Test // // Requires "test.sbk" //------------------------------------------------------------------ // #if defined(BUILD_SND_PLAY) { MIDIValue channel; MIDIValue progSelect; int noteIsOn, prognum; char ch; Tell("AudioHardware::TestClass\n"); // // Load SBKs // audio_hardware.frontCard.LoadSBK("test.sbk"); audio_hardware.rearCard.LoadSBK("test.sbk"); // // Init channel // Set to second bank // channel = 0; // Card 1 audio_hardware.frontCard.SendController( channel, MIDI_CONTROL_RESET, 1 ); audio_hardware.frontCard.SendController( channel, MIDI_PAN_CONTROL, MIDI_CENTER_PAN_VALUE ); audio_hardware.frontCard.SendController( channel, MIDI_REVERB_CONTROL, MIDI_MIN_CONTROL_VALUE ); audio_hardware.frontCard.SendController( channel, MIDI_CHORUS_CONTROL, MIDI_MIN_CONTROL_VALUE ); audio_hardware.frontCard.SelectBank(channel, 1); // Card 2 audio_hardware.rearCard.SendController( channel, MIDI_CONTROL_RESET, 1 ); audio_hardware.rearCard.SendController( channel, MIDI_PAN_CONTROL, MIDI_CENTER_PAN_VALUE ); audio_hardware.rearCard.SendController( channel, MIDI_REVERB_CONTROL, MIDI_MIN_CONTROL_VALUE ); audio_hardware.rearCard.SendController( channel, MIDI_CHORUS_CONTROL, MIDI_MIN_CONTROL_VALUE ); audio_hardware.rearCard.SelectBank(channel, 1); // // Select program number // Tell("\nPlay program number (-1 to quit): "); cin >> prognum; progSelect = (MIDIValue)prognum; Tell("\nPress to start or stop playing.\n"); Tell("Hit to select a new program.\n"); while (prognum != -1) { // Set Program audio_hardware.frontCard.SendProgramChange(channel, progSelect); audio_hardware.rearCard.SendProgramChange(channel, progSelect); audio_hardware.frontCard.SendNoteOn(channel, 60, 127); audio_hardware.rearCard.SendNoteOn(channel, 60, 127); noteIsOn = 1; ch = (char)getch(); while (ch != ''){ if (ch == ' ') if (noteIsOn){ Tell(" Note off\n"); audio_hardware.frontCard.SendNoteOff(channel, 60, 0); audio_hardware.rearCard.SendNoteOff(channel, 60, 0); noteIsOn = 0; } else { Tell(" Note on\n"); audio_hardware.frontCard.SendNoteOn(channel, 60, 127); audio_hardware.rearCard.SendNoteOn(channel, 60, 127); noteIsOn = 1; } ch = (char)getch(); } audio_hardware.frontCard.SendNoteOff(channel, 60, 0); audio_hardware.rearCard.SendNoteOff(channel, 60, 0); Tell("\nPlay program number (-1 to quit): "); cin >> prognum; progSelect = (MIDIValue)prognum; } } #endif // //------------------------------------------------------------------ // Sequence through channels and notes //------------------------------------------------------------------ // #if 0 { MIDIValue channel; MIDIValue key; // // Init channels // for (channel = 0; channel < 16; channel++) { // // Set to first bank, first program // // Card 1 audio_hardware.frontCard.SendController(channel, 0, 0); audio_hardware.frontCard.SendProgramChange(channel, 0); // Card 2 audio_hardware.rearCard.SendController(channel, 0, 0); audio_hardware.rearCard.SendProgramChange(channel, 0); } // // Play sequence of keys // Tell("Sequence through channels and notes - Press ESC to stop\n"); for (channel = 0; channel < 16; channel++) { for (key = 60; key < 60+12; key++) { clock_t next_key_time; Tell("channel " << (int)channel << " key " << (int)key << "\n"); // Card 1 audio_hardware.frontCard.SendNoteOn(channel, key, 127); // Card 2 audio_hardware.rearCard.SendNoteOn(channel, key, 127); next_key_time = clock() + CLOCKS_PER_SEC/10; while (clock() < next_key_time) { } } for (key = 60; key < 60+12; key++) { // Card 1 audio_hardware.frontCard.SendNoteOff(channel, key, 127); // Card 2 audio_hardware.rearCard.SendNoteOff(channel, key, 127); } if (kbhit()) { if (getch() == '') break; } } } #endif // //------------------------------------------------------------------ // Sequence through programs //------------------------------------------------------------------ // #if 0 { clock_t end_time; MIDIValue channel; MIDIValue program; // // Init channels // for (channel = 0; channel < 16; channel++) { // // Set to second bank // // Card 1 audio_hardware.frontCard.SendController(channel, 121, 1); // Reset audio_hardware.frontCard.SendController(channel, 0, 1); // Card 2 audio_hardware.rearCard.SendController(channel, 121, 1); // Reset audio_hardware.rearCard.SendController(channel, 0, 1); } // // Sequence through programs // for (program = 0; program < 128; program++) { // // Set program // audio_hardware.frontCard.SendProgramChange(0, program); audio_hardware.rearCard.SendProgramChange(0, program); Tell("Program " << (int)program << "\n"); // // Play note // audio_hardware.frontCard.SendNoteOn(0, 60, 127); audio_hardware.rearCard.SendNoteOn(0, 60, 127); end_time = clock() + 8*CLOCKS_PER_SEC; while (clock() < end_time) { } audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNoteOff(0, 60, 0); if (kbhit()) { if (getch() == '') break; } } } #endif // //------------------------------------------------------------------ // Test front volume controller //------------------------------------------------------------------ // #if 0 { clock_t start_time, period, end_time; float fvol; MIDIValue vol; // // Modulate volume // Tell("Volume should be modulated in the front\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); period = 2*CLOCKS_PER_SEC; start_time = clock(); end_time = start_time + 4*period; while (clock() < end_time) { fvol = sin(RAD360 * (float)(clock() - start_time) / (float)period); fvol += 1.0; fvol *= 63.0; vol = fvol; // Card 1 audio_hardware.frontCard.SendController(0, 7, vol); Tell(" vol " << (int)vol); if (kbhit()) { if (getch() == '') break; } } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendController(0, 7, 127); Tell("\n"); } #endif // //------------------------------------------------------------------ // Test rear volume controller //------------------------------------------------------------------ // #if 0 { clock_t start_time, period, end_time; float fvol; MIDIValue vol; // // Modulate volume // Tell("Volume should be modulated in the rear\n"); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 2); // Pgm audio_hardware.rearCard.SendController(0, 10, 63); // Pan Center audio_hardware.rearCard.SendNoteOn(0, 60, 127); period = 2*CLOCKS_PER_SEC; start_time = clock(); end_time = start_time + 4*period; while (clock() < end_time) { fvol = sin(RAD360 * (float)(clock() - start_time) / (float)period); fvol += 1.0; fvol *= 63.0; vol = fvol; // Card 2 audio_hardware.rearCard.SendController(0, 7, vol); Tell(" vol " << (int)vol); if (kbhit()) { if (getch() == '') break; } } // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendController(0, 7, 127); Tell("\n"); } #endif // //------------------------------------------------------------------ // Test pan controller //------------------------------------------------------------------ // #if 0 { clock_t end_time; // Card 1 audio_hardware.frontCard.SendController(0, 91, 0); // Reverb audio_hardware.frontCard.SendController(0, 93, 0); // Chorus // Card 2 audio_hardware.rearCard.SendController(0, 91, 0); // Reverb audio_hardware.rearCard.SendController(0, 93, 0); // Chorus // // Pan left // // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 0); // Pgm audio_hardware.frontCard.SendController(0, 10, 0); // Pan left audio_hardware.frontCard.SendNoteOn(0, 60, 127); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 0); // Pgm audio_hardware.rearCard.SendController(0, 10, 0); // Pan left audio_hardware.rearCard.SendNoteOn(0, 60, 127); Tell("Note should be panned left\n"); end_time = clock() + 4*CLOCKS_PER_SEC; while (clock() < end_time) { } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); // // Pan Right // // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 1); // Pgm audio_hardware.frontCard.SendController(0, 10, 127); // Pan right audio_hardware.frontCard.SendNoteOn(0, 60, 127); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 1); // Pgm audio_hardware.rearCard.SendController(0, 10, 127); // Pan right audio_hardware.rearCard.SendNoteOn(0, 60, 127); Tell("Note should be panned right\n"); end_time = clock() + 4*CLOCKS_PER_SEC; while (clock() < end_time) { } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); } #endif // //------------------------------------------------------------------ // Test pitch bend //------------------------------------------------------------------ // #if 0 { clock_t start_time, period, end_time; float fpitch; MIDIPitchBend pitch; // // Modulate pitch // Tell("Pitch should be modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 2); // Pgm audio_hardware.rearCard.SendController(0, 10, 63); // Pan Center audio_hardware.rearCard.SendNoteOn(0, 60, 127); period = 2*CLOCKS_PER_SEC; start_time = clock(); end_time = start_time + 4*period; while (clock() < end_time) { fpitch = sin(RAD360 * (float)(clock() - start_time) / (float)period); fpitch += 1.0; fpitch *= 8191.0; pitch = fpitch; // Card 1 audio_hardware.frontCard.SendPitchBend(0, pitch); // Card 2 audio_hardware.rearCard.SendPitchBend(0, pitch); Tell("pitch " << (int)pitch << "\n"); if (kbhit()) { if (getch() == '') break; } } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendPitchBend(0, 8192); // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendPitchBend(0, 8192); } #endif // //------------------------------------------------------------------ // Test pitch NRPN //------------------------------------------------------------------ // #if 0 { clock_t start_time, period, end_time; float fpitch; MIDINRPNValue pitch; // // Modulate pitch // Tell("Pitch should be modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 2); // Pgm audio_hardware.rearCard.SendController(0, 10, 63); // Pan Center audio_hardware.rearCard.SendNoteOn(0, 60, 127); period = 2*CLOCKS_PER_SEC; start_time = clock(); end_time = start_time + 4*period; while (clock() < end_time) { fpitch = sin(RAD360 * (float)(clock() - start_time) / (float)period); fpitch *= 8191.0; pitch = fpitch; // Card 1 audio_hardware.frontCard.SendNRPN(0, 16, pitch); // Card 2 audio_hardware.rearCard.SendNRPN(0, 16, pitch); Tell("pitch " << (int)pitch << "\n"); if (kbhit()) { if (getch() == '') break; } } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendNRPN(0, 16, 0); // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNRPN(0, 16, 0); } #endif // //------------------------------------------------------------------ // Test filter cutoff NRPN //------------------------------------------------------------------ // #if 0 { clock_t start_time, period, end_time; float fcutoff; MIDINRPNValue cutoff; // // Modulate filter cutoff // Tell("Filter cutoff should be modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 1); // Bank audio_hardware.rearCard.SendProgramChange(0, 2); // Pgm audio_hardware.rearCard.SendController(0, 10, 63); // Pan Center audio_hardware.rearCard.SendNoteOn(0, 60, 127); period = 2*CLOCKS_PER_SEC; start_time = clock(); end_time = start_time + 4*period; while (clock() < end_time) { fcutoff = sin(RAD360 * (float)(clock() - start_time) / (float)period); fcutoff += 1.0; fcutoff *= 63.0; cutoff = fcutoff; // Card 1 audio_hardware.frontCard.SendNRPN(0, 21, cutoff); // Card 2 audio_hardware.rearCard.SendNRPN(0, 21, cutoff); Tell("cutoff " << (int)cutoff << "\n"); if (kbhit()) { if (getch() == '') break; } } // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendNRPN(0, 21, 127); // Card 2 audio_hardware.rearCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNRPN(0, 21, 127); } #endif // //------------------------------------------------------------------ // Test reverb and chorus settings //------------------------------------------------------------------ // #if 0 { clock_t end_time; int i; // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 0); // Bank audio_hardware.frontCard.SendProgramChange(0, 0); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center // Card 2 audio_hardware.rearCard.SendController(0, 121, 1); // Reset audio_hardware.rearCard.SendController(0, 0, 0); // Bank audio_hardware.rearCard.SendProgramChange(0, 0); // Pgm audio_hardware.rearCard.SendController(0, 10, 63); // Pan Center // Card 1 audio_hardware.frontCard.SendController(0, 91, 127); // Reverb audio_hardware.frontCard.SendController(0, 93, 0); // Chorus // Card 2 audio_hardware.rearCard.SendController(0, 91, 127); // Reverb audio_hardware.rearCard.SendController(0, 93, 0); // Chorus for (i = 0; i < 8; i++) { #pragma warn -sig audio_hardware.frontCard.SelectEffect(ReverbMIDIEffectType, i); // Reverb audio_hardware.rearCard.SelectEffect(ReverbMIDIEffectType, i); // Reverb #pragma warn +sig Tell("Reverb " << i << "\n"); audio_hardware.frontCard.SendNoteOn(0, 60, 127); audio_hardware.rearCard.SendNoteOn(0, 60, 127); end_time = clock() + 3*CLOCKS_PER_SEC; while (clock() < end_time) { } audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNoteOff(0, 60, 0); if (kbhit()) { if (getch() == '') break; } } // Card 1 audio_hardware.frontCard.SendController(0, 91, 0); // Reverb audio_hardware.frontCard.SendController(0, 93, 127); // Chorus // Card 2 audio_hardware.rearCard.SendController(0, 91, 0); // Reverb audio_hardware.rearCard.SendController(0, 93, 127); // Chorus for (i = 0; i < 8; i++) { #pragma warn -sig audio_hardware.frontCard.SelectEffect(ChorusMIDIEffectType, i); // Chorus audio_hardware.rearCard.SelectEffect(ChorusMIDIEffectType, i); // Chorus #pragma warn +sig Tell("Chorus " << i << "\n"); audio_hardware.frontCard.SendNoteOn(0, 60, 127); audio_hardware.rearCard.SendNoteOn(0, 60, 127); end_time = clock() + 3*CLOCKS_PER_SEC; while (clock() < end_time) { } audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.rearCard.SendNoteOff(0, 60, 0); if (kbhit()) { if (getch() == '') break; } } } #endif // // Close down // audio_hardware.Close(); return True; } // //############################################################################# // ProfileClass //############################################################################# // #define RAD360 (6.28318) Logical AudioHardware::ProfileClass() { AudioHardware audio_hardware; Tell("AudioHardware::ProfileClass\n"); // // Init the audio hardware // audio_hardware.Initialize(); audio_hardware.frontCard.LoadSBK("test.sbk"); audio_hardware.rearCard.LoadSBK("test.sbk"); // //------------------------------------------------------------------ // Sequence through channels and notes //------------------------------------------------------------------ // #if 0 { clock_t start_timer, total_timer; int number_of_calls; MIDIValue channel; MIDIValue key; // // Init channels // for (channel = 0; channel < 16; channel++) { // // Set to first bank, first program // // Card 1 audio_hardware.frontCard.SendController(channel, 0, 0); audio_hardware.frontCard.SendProgramChange(channel, 0); // Card 2 audio_hardware.rearCard.SendController(channel, 0, 0); audio_hardware.rearCard.SendProgramChange(channel, 0); } // // Play sequence of keys // Tell("Sequence through channels and notes\n"); total_timer = 0; start_timer = clock(); for (channel = 0; channel < 16; channel++) { for (key = 0; key < 128; key++) { // Card 1 audio_hardware.frontCard.SendNoteOn(channel, key, 127); // Card 2 audio_hardware.rearCard.SendNoteOn(channel, key, 127); } for (key = 0; key < 128; key++) { // Card 1 audio_hardware.frontCard.SendNoteOff(channel, key, 127); // Card 2 audio_hardware.rearCard.SendNoteOff(channel, key, 127); } } total_timer += clock() - start_timer; number_of_calls = 16 * 2 * 128 * 2; Tell("Calls " << number_of_calls << " Duration " << total_timer << "\n"); Tell( "Calls 1000 Duration " << (Scalar)total_timer / (Scalar)number_of_calls << " secs\n" ); } #endif // //------------------------------------------------------------------ // Test front volume controller //------------------------------------------------------------------ // #if 0 { clock_t start_timer, total_timer; int number_of_calls, i; // // Modulate volume // Tell("Volume modulated in the front\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); number_of_calls = 100000; i = 0; total_timer = 0; start_timer = clock(); while (i < number_of_calls) { // Card 1 audio_hardware.frontCard.SendController(0, 7, (MIDIValue)i); i++; } total_timer += clock() - start_timer; Tell("Calls " << number_of_calls << " Duration " << total_timer << "\n"); Tell( "Calls 1000 Duration " << (Scalar)total_timer / (Scalar)number_of_calls << " secs\n" ); // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendController(0, 7, 127); } #endif // //------------------------------------------------------------------ // Test pitch bend //------------------------------------------------------------------ // #if 0 { clock_t start_timer, total_timer; int number_of_calls, i; // // Modulate pitch // Tell("Pitch modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); number_of_calls = 100000; i = 0; total_timer = 0; start_timer = clock(); while (i < number_of_calls) { audio_hardware.frontCard.SendPitchBend(0, i); i++; } total_timer += clock() - start_timer; Tell("Calls " << number_of_calls << " Duration " << total_timer << "\n"); Tell( "Calls 1000 Duration " << (Scalar)total_timer / (Scalar)number_of_calls << " secs\n" ); // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendPitchBend(0, 8192); } #endif // //------------------------------------------------------------------ // Test pitch NRPN //------------------------------------------------------------------ // #if 0 { clock_t start_timer, total_timer; int number_of_calls, i; // // Modulate pitch // Tell("Pitch NRPN modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); number_of_calls = 100000; i = 0; total_timer = 0; start_timer = clock(); while (i < number_of_calls) { audio_hardware.frontCard.SendNRPN(0, 16, i); i++; } total_timer += clock() - start_timer; Tell("Calls " << number_of_calls << " Duration " << total_timer << "\n"); Tell( "Calls 1000 Duration " << (Scalar)total_timer / (Scalar)number_of_calls << " secs\n" ); // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendNRPN(0, 16, 0); } #endif // //------------------------------------------------------------------ // Test filter NRPN //------------------------------------------------------------------ // #if 0 { clock_t start_timer, total_timer; int number_of_calls, i; // // Modulate pitch // Tell("Filter NRPN modulated\n"); // Card 1 audio_hardware.frontCard.SendController(0, 121, 1); // Reset audio_hardware.frontCard.SendController(0, 0, 1); // Bank audio_hardware.frontCard.SendProgramChange(0, 2); // Pgm audio_hardware.frontCard.SendController(0, 10, 63); // Pan Center audio_hardware.frontCard.SendNoteOn(0, 60, 127); number_of_calls = 100000; i = 0; total_timer = 0; start_timer = clock(); while (i < number_of_calls) { audio_hardware.frontCard.SendNRPN(0, 21, i); i++; } total_timer += clock() - start_timer; Tell("Calls " << number_of_calls << " Duration " << total_timer << "\n"); Tell( "Calls 1000 Duration " << (Scalar)total_timer / (Scalar)number_of_calls << " secs\n" ); // Card 1 audio_hardware.frontCard.SendNoteOff(0, 60, 0); audio_hardware.frontCard.SendNRPN(0, 21, 127); } #endif // // Close down // audio_hardware.Close(); return True; }