2012-06-17 23:14:24 -05:00
|
|
|
/**
|
2014-07-10 14:07:07 -05:00
|
|
|
* @file
|
|
|
|
|
* @brief Source code to play a test sound
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
|
|
|
|
* <http://www.openshotstudios.com/>. This file is part of OpenShot Audio
|
|
|
|
|
* Library (libopenshot-audio), an open-source project dedicated to delivering
|
2014-07-15 13:24:12 -05:00
|
|
|
* high quality audio editing and playback solutions to the world. For more
|
2014-07-10 14:07:07 -05:00
|
|
|
* information visit <http://www.openshot.org/>.
|
|
|
|
|
*
|
|
|
|
|
* OpenShot Audio Library (libopenshot-audio) is free software: you can
|
2014-07-15 13:24:12 -05:00
|
|
|
* redistribute it and/or modify it under the terms of the GNU General
|
2014-07-10 14:07:07 -05:00
|
|
|
* Public License as published by the Free Software Foundation, either version
|
|
|
|
|
* 3 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* OpenShot Audio Library (libopenshot-audio) is distributed in the hope that
|
|
|
|
|
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-07-15 13:24:12 -05:00
|
|
|
* GNU General Public License for more details.
|
2014-07-10 14:07:07 -05:00
|
|
|
*
|
2014-07-15 13:24:12 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-07-10 14:07:07 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* @mainpage OpenShot Audio Library C++ API
|
2012-08-08 12:36:29 -05:00
|
|
|
*
|
|
|
|
|
* Welcome to the OpenShot Audio Library C++ API. This library is used by libopenshot to enable audio
|
|
|
|
|
* features, which powers the <a href="http://www.openshot.org">OpenShot Video Editor</a> application.
|
|
|
|
|
*/
|
2013-06-09 01:09:34 -05:00
|
|
|
|
2012-06-17 23:14:24 -05:00
|
|
|
#include <iostream>
|
2013-02-06 02:09:54 -06:00
|
|
|
#include <unistd.h>
|
2012-06-15 17:45:27 -05:00
|
|
|
#include "../JuceLibraryCode/JuceHeader.h"
|
|
|
|
|
|
2012-06-22 01:29:22 -05:00
|
|
|
#if JUCE_MINGW
|
2015-09-03 16:10:03 -05:00
|
|
|
#define sleep(a) Sleep(a * 1000)
|
|
|
|
|
#include <windows.h>
|
2012-06-22 01:29:22 -05:00
|
|
|
#endif
|
|
|
|
|
|
2012-06-17 23:14:24 -05:00
|
|
|
using namespace std;
|
|
|
|
|
|
2012-06-15 17:45:27 -05:00
|
|
|
//==============================================================================
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
|
2012-06-17 23:14:24 -05:00
|
|
|
// Initialize audio devices
|
2015-09-03 16:10:03 -05:00
|
|
|
cout << "Begin init" << endl;
|
2012-06-17 23:14:24 -05:00
|
|
|
AudioDeviceManager deviceManager;
|
|
|
|
|
deviceManager.initialise ( 0, /* number of input channels */
|
|
|
|
|
2, /* number of output channels */
|
|
|
|
|
0, /* no XML settings.. */
|
|
|
|
|
true /* select default device on failure */);
|
|
|
|
|
|
2015-09-03 16:10:03 -05:00
|
|
|
// Play test sound
|
|
|
|
|
cout << "Playing sound now" << endl;
|
|
|
|
|
deviceManager.playTestSound();
|
|
|
|
|
for (int x = 1; x <= 5; x++) {
|
|
|
|
|
cout << "... " << x << endl;
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int id = 1;
|
|
|
|
|
cout << "before device loop" << endl;
|
|
|
|
|
for (int i = 0; i < deviceManager.getAvailableDeviceTypes().size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const AudioIODeviceType* t = deviceManager.getAvailableDeviceTypes()[i];
|
|
|
|
|
const StringArray deviceNames = t->getDeviceNames ();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < deviceNames.size (); ++j )
|
|
|
|
|
{
|
|
|
|
|
const String deviceName = deviceNames[j];
|
|
|
|
|
String menuName;
|
|
|
|
|
|
|
|
|
|
menuName << deviceName << " (" << t->getTypeName() << ")";
|
|
|
|
|
cout << menuName << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cout << "after device loop" << endl;
|
2012-06-17 23:14:24 -05:00
|
|
|
|
|
|
|
|
// Stop audio devices
|
2015-09-03 16:10:03 -05:00
|
|
|
deviceManager.closeAudioDevice();
|
|
|
|
|
deviceManager.removeAllChangeListeners();
|
|
|
|
|
deviceManager.dispatchPendingMessages();
|
2012-06-17 23:14:24 -05:00
|
|
|
|
2015-09-03 16:10:03 -05:00
|
|
|
return 0;
|
2012-06-15 17:45:27 -05:00
|
|
|
}
|