本文整理汇总了C++中AudioDeviceManager::initialise方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDeviceManager::initialise方法的具体用法?C++ AudioDeviceManager::initialise怎么用?C++ AudioDeviceManager::initialise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioDeviceManager
的用法示例。
在下文中一共展示了AudioDeviceManager::initialise方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialise
//==============================================================================
void initialise (const String& /*commandLine*/)
{
// MANAGER
myAudioManager = new AudioDeviceManager();
String error = myAudioManager->initialise(2, 2, 0, true);
DBG("error string : " + String(error));
myAudioProcessor = new MainAudioProcessor();
myAudioProcessor->prepareToPlay(44100, 512);
myProcessorPlayer = new AudioProcessorPlayer();
myProcessorPlayer->setProcessor(myAudioProcessor);
myAudioManager->addAudioCallback(myProcessorPlayer);
theMainWindow = new MainDemoWindow(myAudioProcessor);
theMainWindow->centreWithSize (700, 600);
theMainWindow->setVisible (true);
}
示例2: initialise
//==============================================================================
void initialise (const String& commandLine)
{
DBG("Initialising OwlNest");
ApplicationConfiguration::initialise();
commands = new ApplicationCommandManager();
commands->registerAllCommandsForTarget(this);
commands->registerAllCommandsForTarget(&settings);
commands->setFirstCommandTarget(&settings);
// Initialize audio/midi device
PropertySet* props = ApplicationConfiguration::getApplicationProperties();
if(props->getBoolValue("hide-low-level-items") == true)
{
dm.initialise(0, 0, nullptr, true);
}
else
{
dm.initialise(2, 2, nullptr, true);
}
// start GUI
mainWindow = new MainWindow(commands, settings, dm, updateGui);
mainWindow->addKeyListener(commands->getKeyMappings());
}
示例3: initJuceAudio
void initJuceAudio(void){
XmlElement *settings=propertiesfile->getXmlValue("audiodevicemanager");
const String error (audioDeviceManager.initialise (0, /* number of input channels */
8, /* number of output channels */
settings,
true /* select default device on failure */));
if (audioDeviceManager.getCurrentAudioDevice()==NULL || error.isNotEmpty())
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
T("Mammut"),
T("Couldn't open an output device!\n\n") + error);
}
else
{
isinitialized=true;
// start the IO device pulling its data from our callback..
audioDeviceManager.setAudioCallback (this);
}
}
示例4: Play
// Play audio samples for this frame
void Frame::Play()
{
// Check if samples are present
if (!audio->getNumSamples())
return;
AudioDeviceManager deviceManager;
deviceManager.initialise (0, /* number of input channels */
2, /* number of output channels */
0, /* no XML settings.. */
true /* select default device on failure */);
//deviceManager.playTestSound();
AudioSourcePlayer audioSourcePlayer;
deviceManager.addAudioCallback (&audioSourcePlayer);
ScopedPointer<AudioBufferSource> my_source;
my_source = new AudioBufferSource(audio.get());
// Create TimeSliceThread for audio buffering
TimeSliceThread my_thread("Audio buffer thread");
// Start thread
my_thread.startThread();
AudioTransportSource transport1;
transport1.setSource (my_source,
5000, // tells it to buffer this many samples ahead
&my_thread,
(double) sample_rate,
audio->getNumChannels()); // sample rate of source
transport1.setPosition (0);
transport1.setGain(1.0);
// Create MIXER
MixerAudioSource mixer;
mixer.addInputSource(&transport1, false);
audioSourcePlayer.setSource (&mixer);
// Start transports
transport1.start();
while (transport1.isPlaying())
{
cout << "playing" << endl;
Sleep(1);
}
cout << "DONE!!!" << endl;
transport1.stop();
transport1.setSource (0);
audioSourcePlayer.setSource (0);
my_thread.stopThread(500);
deviceManager.removeAudioCallback (&audioSourcePlayer);
deviceManager.closeAudioDevice();
deviceManager.removeAllChangeListeners();
deviceManager.dispatchPendingMessages();
cout << "End of Play()" << endl;
}
示例5: main
//==============================================================================
int main( int argc, char* argv[] )
{
AudioDeviceManager* dm = new AudioDeviceManager();
auto callback = new SimpleCallback();
const OwnedArray< AudioIODeviceType >* deviceTypes = &( dm->getAvailableDeviceTypes() );
for ( auto& t : *( deviceTypes ) ) {
DBG( "+-- device type : ------------+" );
DBG( " " + t->getTypeName() );
t->scanForDevices();
if ( t->hasSeparateInputsAndOutputs() ) {
DBG( "+-- inputs : ------------+" );
auto deviceNames = t->getDeviceNames( true );
for ( auto& name : deviceNames ) {
DBG( " +-- device name : ------------+" );
DBG( " " + name );
}
DBG( "+-- outputs : ------------+" );
deviceNames = t->getDeviceNames( false );
for ( auto& name : deviceNames ) {
DBG( " +-- device name : ------------+" );
DBG( " " + name );
}
} else {
}
DBG( "has separate inputs and outputs : " << t->hasSeparateInputsAndOutputs() );
}
// initialize audio with the following requirements:
auto result =
dm->initialise( /* num inputs */ 0, /* num outputs */ 2, /* xml settings file */ nullptr,
/* select default device on failure */ true );
if ( !result.isEmpty() ) {
DBG( "Error on initialize : " + result );
}
logMessage( "--------------------------------------" );
logMessage( "Current audio device type: " +
( dm->getCurrentDeviceTypeObject() != nullptr
? dm->getCurrentDeviceTypeObject()->getTypeName()
: "<none>" ) );
if ( AudioIODevice* device = dm->getCurrentAudioDevice() ) {
logMessage( "Current audio device: " + device->getName().quoted() );
logMessage( "Sample rate: " + String( device->getCurrentSampleRate() ) + " Hz" );
logMessage( "Block size: " + String( device->getCurrentBufferSizeSamples() ) + " samples" );
logMessage( "Output Latency: " + String( device->getOutputLatencyInSamples() ) +
" samples" );
logMessage( "Input Latency: " + String( device->getInputLatencyInSamples() ) + " samples" );
logMessage( "Bit depth: " + String( device->getCurrentBitDepth() ) );
logMessage( "Input channel names: " +
device->getInputChannelNames().joinIntoString( ", " ) );
logMessage( "Active input channels: " +
getListOfActiveBits( device->getActiveInputChannels() ) );
logMessage( "Output channel names: " +
device->getOutputChannelNames().joinIntoString( ", " ) );
logMessage( "Active output channels: " +
getListOfActiveBits( device->getActiveOutputChannels() ) );
} else {
logMessage( "No audio device open" );
}
dm->addAudioCallback( callback );
sleep( 3 ); // 3 seconds of audio
// while ( true ) {
// }
dm->removeAudioCallback( callback );
delete callback;
delete dm;
return 0;
}