// Implementations AUDIOAPI AudioPlayerPtr MakeGroupPlayer() { int res; const int n_out_channels = 2; TAudioGlobals::ClearLibError(); IntAudioPlayerPtr player = static_cast<IntAudioPlayerPtr>(calloc(1, sizeof(AudioPlayer))); if (!player) { goto error; } player->fRenderer = new TGroupRenderer; res = player->fRenderer->Open(TAudioGlobals::fInput, n_out_channels, TAudioGlobals::fBufferSize, TAudioGlobals::fSampleRate); if (!player->fRenderer) { goto error; } player->fMixer = new TGroupAudioMixer{TAudioGlobals::fBufferSize, n_out_channels}; if (!player->fMixer) { goto error; } player->fRenderer->AddClient(player->fMixer); if (res == NO_ERR) { return player; } error: CloseAudioPlayer(player); return 0; }
void ApplicationPlugin::stopEngine() { if(m_ctx.player) { StopAudioPlayer(m_ctx.player); CloseAudioPlayer(m_ctx.player); } m_ctx.player = nullptr; m_ctx.renderer = nullptr; m_ctx.device_info = DeviceInfo{}; m_ctx.renderer_info = RendererInfo{}; }
void ApplicationPlugin::startEngine() { // Initialize libaudiostream structures if(m_ctx.player) { StopAudioPlayer(m_ctx.player); CloseAudioPlayer(m_ctx.player); } GetDeviceInfo(kJackRenderer, 0, &m_ctx.device_info); auto& dev = m_ctx.device_info; qDebug() << dev.fName << dev.fMaxInputChannels << dev.fMaxOutputChannels << dev.fDefaultBufferSize << dev.fDefaultSampleRate; m_ctx.player = OpenAudioPlayer(0, 2, 44100, 512, 65536*4, 44100*60*20, kJackRenderer, 1); m_ctx.renderer = GetAudioPlayerRenderer(m_ctx.player); GetAudioRendererInfo(m_ctx.renderer, &m_ctx.renderer_info); }
int main(int argc, char* argv[]) { printf("----------------------------\n"); printf("LibAudioStream based Player \n"); printf("----------------------------\n\n"); int res = LibVersion(); ///int samplerate = 96000; int samplerate = 44100; #ifndef WIN32 SetMaximumFiles(1024); printf("sysconf id_max %ld\n", sysconf(_SC_OPEN_MAX)); #endif // Try to open Jack version AudioPlayerPtr player = OpenAudioPlayer(IN_CHANNELS, OUT_CHANNELS, CHANNELS, samplerate, 512, 65536 * 8, 131072 * 4, kJackRenderer, 1); // If failure opens PortAudio version if (!player) { player = OpenAudioPlayer(IN_CHANNELS, OUT_CHANNELS, CHANNELS, samplerate, 1024, 65536 * 8, 131072 * 8, kPortAudioRenderer, 1); } // If failure opens CoreAudio version if (!player) { player = OpenAudioPlayer(IN_CHANNELS, OUT_CHANNELS, CHANNELS, samplerate, 1024, 65536 * 8, 131072 * 8, kCoreAudioRenderer, 1); } StartAudioPlayer(player); printf("Type 'b' to start playing from the begining\n"); printf("Type 's' to stop playing\n"); printf("Type 'p' to play from the current position\n"); printf("Type '+' to raise volume\n"); printf("Type '-' to lower volume\n"); printf("Type '1' to pan left\n"); printf("Type '2' to pan right\n"); printf("Type 'n' to go to next test\n"); /* ExecTest(player, test0()); ExecTest(player, test0()); ExecTest(player, test0()); ExecTest(player, test0()); ExecTest(player, test0()); ExecTest(player, test0()); ExecTest(player, test0()); */ ExecTest(player, test0()); ExecTest(player, test1()); ExecTest(player, test1()); ExecTest(player, test2()); ExecTest(player, test3()); ExecTest(player, test4()); ExecTest(player, test5()); ExecTest(player, test6()); ExecTest(player, test7()); ExecTest(player, test8()); ExecTest(player, test9()); ExecTest(player, test9bis()); //ExecTest(player, test10()); ExecTest(player, test10bis()); //ExecTest(player, test11()); ExecTest(player, test11bis()); ExecTest(player, test12()); ExecTest(player, test13()); /* test20(); test21(); */ //ExecTest(player, test0()); StopAudioPlayer(player); CloseAudioPlayer(player); printf("Quit\n"); return 0; }