//============================================================================== TargetFileComponent::TargetFileComponent (AudioDeviceManager& deviceManager) : deviceManager(deviceManager) { addAndMakeVisible (viewport = new Viewport()); viewport->setName ("viewport"); addAndMakeVisible (container = new TargetContainer()); container->setName ("container"); addAndMakeVisible (playButton = new TextButton ("playButton")); playButton->setButtonText ("Play"); playButton->addListener (this); addAndMakeVisible (stopButton = new TextButton ("stopButton")); stopButton->setButtonText ("Stop"); stopButton->addListener (this); addAndMakeVisible (loadFileButton = new TextButton ("loadFileButton")); loadFileButton->setButtonText ("Load Target File"); loadFileButton->addListener (this); loadFileButton->setColour (TextButton::buttonColourId, Colour (0xfffbfbfd)); addAndMakeVisible (zoomLabel = new Label ("zoomLabel", "ZoomX")); zoomLabel->setFont (Font (15.00f, Font::plain)); zoomLabel->setJustificationType (Justification::centredLeft); zoomLabel->setEditable (false, false, false); zoomLabel->setColour (TextEditor::textColourId, Colours::black); zoomLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (zoomSlider = new Slider ("zoomSlider")); zoomSlider->setRange (1, 5, 0.1); zoomSlider->setSliderStyle (Slider::LinearHorizontal); zoomSlider->setTextBoxStyle (Slider::TextBoxLeft, true, 35, 20); zoomSlider->addListener (this); //[UserPreSize] //[/UserPreSize] setSize (600, 400); //[Constructor] You can add your own custom stuff here.. viewport->setViewedComponent(container, false); isPlayable = false; setPlayable(isPlayable); deviceManager.addAudioCallback(&audioSourcePlayer); audioSourcePlayer.setSource(&audioTransport); container->addActionListener(this); currentFile = new SegaudioFile(); //[/Constructor] }
//============================================================================== 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); }
void init(base::lisp &gl) { fm.registerBasicFormats(); thread.startThread(3); dm.addAudioCallback(&asp); asp.setSource(&ts); pl = new playbackListener(gl); ts.addChangeListener(pl); }
// 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; }
//============================================================================== 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; }