当前位置: 首页>>代码示例>>C++>>正文


C++ AudioDeviceManager类代码示例

本文整理汇总了C++中AudioDeviceManager的典型用法代码示例。如果您正苦于以下问题:C++ AudioDeviceManager类的具体用法?C++ AudioDeviceManager怎么用?C++ AudioDeviceManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AudioDeviceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
      

    }
开发者ID:aaronleese,项目名称:beat-matching-crossfader,代码行数:26,代码来源:ApplicationStartup.cpp

示例2: theSettings

//==============================================================================
ApplicationSettingsWindow::ApplicationSettingsWindow (OwlControlSettings& settings, AudioDeviceManager& deviceManager)
    : theSettings(settings)
{
    //[Constructor_pre] You can add your own custom stuff here..
    //[/Constructor_pre]

    addAndMakeVisible (audioSelector = new AudioDeviceSelectorComponent (deviceManager,0,0,0,0,true,true,false,false));
    audioSelector->setName ("new component");

    addAndMakeVisible (midiDeviceBox = new ComboBox ("new combo box"));
    midiDeviceBox->setEditableText (false);
    midiDeviceBox->setJustificationType (Justification::centredLeft);
    midiDeviceBox->setTextWhenNothingSelected (String());
    midiDeviceBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
    midiDeviceBox->addItem (TRANS("OMNI"), 1);
    midiDeviceBox->addItem (TRANS("1"), 2);
    midiDeviceBox->addItem (TRANS("2"), 3);
    midiDeviceBox->addItem (TRANS("3"), 4);
    midiDeviceBox->addItem (TRANS("4"), 5);
    midiDeviceBox->addItem (TRANS("5"), 6);
    midiDeviceBox->addItem (TRANS("6"), 7);
    midiDeviceBox->addItem (TRANS("7"), 8);
    midiDeviceBox->addItem (TRANS("8"), 9);
    midiDeviceBox->addItem (TRANS("9"), 10);
    midiDeviceBox->addItem (TRANS("10"), 11);
    midiDeviceBox->addItem (TRANS("11"), 12);
    midiDeviceBox->addItem (TRANS("12"), 13);
    midiDeviceBox->addItem (TRANS("13"), 14);
    midiDeviceBox->addItem (TRANS("14"), 15);
    midiDeviceBox->addItem (TRANS("15"), 16);
    midiDeviceBox->addItem (TRANS("16"), 17);
    midiDeviceBox->addListener (this);

    addAndMakeVisible (label = new Label ("new label",
                                          TRANS("MIDI Device")));
    label->setFont (Font (15.00f, Font::plain));
    label->setJustificationType (Justification::centredLeft);
    label->setEditable (false, false, false);
    label->setColour (TextEditor::textColourId, Colours::black);
    label->setColour (TextEditor::backgroundColourId, Colour (0x00000000));


    //[UserPreSize]

    //[/UserPreSize]

    setSize (600, 400);


    //[Constructor] You can add your own custom stuff here..
    PropertySet* properties = ApplicationConfiguration::getApplicationProperties();
    deviceManager.setDefaultMidiOutput(properties->getValue("midi-output"));
    deviceManager.setMidiInputEnabled(properties->getValue("midi-input"), 1);
    //[/Constructor]
}
开发者ID:pingdynasty,项目名称:OwlControl,代码行数:56,代码来源:ApplicationSettingsWindow.cpp

示例3: getDeviceNames

vector<string> getDeviceNames(bool wantInputs = false) {
    vector<string> result;
    AudioDeviceManager manager;
    auto& types = manager.getAvailableDeviceTypes();
    for (auto& t: types) {
        t->scanForDevices();
        auto names = t->getDeviceNames(wantInputs);
        for (auto& name: names)
            result.push_back(name.trimEnd().toStdString());
    }
    return result;
}
开发者ID:TopRamenGod,项目名称:echomesh,代码行数:12,代码来源:DefaultDevice.cpp

示例4: deviceManager

//==============================================================================
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]
}
开发者ID:scaubrey,项目名称:Segaudio,代码行数:61,代码来源:TargetFileComponent.cpp

示例5: addAndMakeVisible

//==============================================================================
ApplicationSettingsWindow::ApplicationSettingsWindow (AudioDeviceManager& deviceManager)
{
    
    addAndMakeVisible (audioSelector = new AudioDeviceSelectorComponent (deviceManager,0,2,0,2,true,true,false,false));
    audioSelector->setName ("new component");
    
    //[UserPreSize]

    //[/UserPreSize]

    setSize (600, 400);

    //[Constructor] You can add your own custom stuff here..
    PropertySet* properties = ApplicationConfiguration::getApplicationProperties();
    deviceManager.setDefaultMidiOutput(properties->getValue("midi-output"));
    deviceManager.setMidiInputEnabled(properties->getValue("midi-input"), 1);
    //[/Constructor]
}
开发者ID:paulmalyschko,项目名称:OwlNest,代码行数:19,代码来源:ApplicationSettingsWindow.cpp

示例6: main

int main(int argc, char* argv[])
{
    {
        AudioDeviceManager manager;
        //manager.initialize();

        auto playbackDevice = manager.getDefaultPlaybackDevice();
        playbackDevice->initialize();

        //playbackDevice->

        auto captureDevice = manager.getDefaultCaptureDevice();
        captureDevice->initialize();

    }

    return 0;
}
开发者ID:wallstop,项目名称:DX,代码行数:18,代码来源:main.cpp

示例7: openFCDAudio

bool FCDProInput::openFCDAudio(const char* cardname)
{
    AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
    const QList<QAudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();

    for (const auto &itAudio : audioList)
    {
        if (itAudio.deviceName().contains(QString(cardname)))
        {
            int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
            m_fcdAudioInput.start(fcdDeviceIndex, fcd_traits<Pro>::sampleRate);
            int fcdSampleRate = m_fcdAudioInput.getRate();
            qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
                    itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
            m_fcdAudioInput.addFifo(&m_fcdFIFO);
            return true;
        }
    }

    qCritical("FCDProInput::openFCDAudio: device with name %s not found", cardname);
    return false;
}
开发者ID:sigysmund,项目名称:sdrangel,代码行数:22,代码来源:fcdproinput.cpp

示例8: initJuceDevicesIfNeeded

static void initJuceDevicesIfNeeded()
{
    static AudioDeviceManager sDeviceManager;
    static bool needsInit = true;

    if (! needsInit)
        return;

    needsInit = false;
    new JuceCleanup();

    sDeviceManager.createAudioDeviceTypes(gDeviceTypes);

    // remove JACK from device list
    for (int i=0, count=gDeviceTypes.size(); i < count; ++i)
    {
        if (gDeviceTypes[i]->getTypeName() == "JACK")
        {
            gDeviceTypes.remove(i, true);
            break;
        }
    }
}
开发者ID:xuanvu,项目名称:Carla,代码行数:23,代码来源:CarlaEngineJuce.cpp

示例9: initJuceDevicesIfNeeded

static void initJuceDevicesIfNeeded()
{
    static AudioDeviceManager sDeviceManager;

    if (gDeviceTypes.size() != 0)
        return;

    sDeviceManager.createAudioDeviceTypes(gDeviceTypes);

    CARLA_SAFE_ASSERT_RETURN(gDeviceTypes.size() != 0,);

    new JuceCleanup();

    // remove JACK from device list
    for (int i=0, count=gDeviceTypes.size(); i < count; ++i)
    {
        if (gDeviceTypes[i]->getTypeName() == "JACK")
        {
            gDeviceTypes.remove(i, true);
            break;
        }
    }
}
开发者ID:peter1000,项目名称:Carla,代码行数:23,代码来源:CarlaEngineJuce.cpp

示例10: 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;
}
开发者ID:ilzxc,项目名称:CHIPAudioInfo,代码行数:78,代码来源:Main.cpp

示例11: 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;


}
开发者ID:mengqwang2,项目名称:libopenshot,代码行数:65,代码来源:Frame.cpp

示例12: thread

namespace playback {
AudioDeviceManager dm;
AudioFormatManager fm;
AudioSourcePlayer asp;
AudioTransportSource ts;
ScopedPointer<AudioFormatReaderSource> frs;
TimeSliceThread thread("audio playback");

class playbackListener : public ChangeListener {
	base::lisp &gl;
public:
	base::string functionId;
	bool enabled;
	playbackListener(base::lisp &gli) : gl(gli), enabled(false) {}
	void changeListenerCallback(ChangeBroadcaster *source) override {
		if (source == &ts && enabled) {
			gl.eval(base::strs("(", functionId, ")"));
		}
	}
};

playbackListener *pl = nullptr;

void init(base::lisp &gl) {
	fm.registerBasicFormats();
	thread.startThread(3);
	dm.addAudioCallback(&asp);
	asp.setSource(&ts);
	pl = new playbackListener(gl);
	ts.addChangeListener(pl);
}

void shutdown() {
	ts.removeAllChangeListeners();
	ts.setSource(nullptr);
	asp.setSource(nullptr);
	dm.removeAudioCallback(&asp);
	delete pl;
	pl = nullptr;
}

//- LISP API -
// playback-set-file (string)fileName -> t/nil
base::cell_t set_file(base::lisp &gl, base::cell_t c, base::cells_t &) {
	if (base::lisp::validate(c, base::cell::list(1), base::cell::typeString)) {
		const auto &fname = c + 1;

		// stop current playback
		ts.stop();
		ts.setSource(nullptr);
		frs = nullptr;
		AudioFormatReader *r;

		// ectract CUE information (if any)
		std::regex cue("^(.*):(\\d+):(\\d+)$");
		std::smatch result;
		std::regex_search(fname->s, result, cue);
		if (result.size() == 4) {
			// is cue
			int32 start = base::fromStr<int32>(result[2].str());
			int32 end = base::fromStr<int32>(result[3].str());
			int32 duration = end - start;

			AudioFormatReader *tr = fm.createReaderFor(File(result[1].str()));

			// start, end are in frames (1 frame = 1/75 second) - convert to sample
			float samplesInOneSecond = tr->sampleRate; // AudioSubsectionReader will handle channels count
			float startSecond = (float)start / 75.0f;
			float durationSecond = (float)duration / 75.0f;
			float startSample = startSecond * samplesInOneSecond;
			float durationSamples = durationSecond * samplesInOneSecond;

			// some CUE may have 0 length (play to end)
			if (end <= start)
				durationSamples = tr->lengthInSamples;

			r = new AudioSubsectionReader(tr, (int)startSample, (int)durationSamples, true);
		}
		else {
			// regular file
			r = fm.createReaderFor(File(fname->s));
		}

		if (r) {
			frs = new AudioFormatReaderSource(r, true);
			ts.setSource(frs, 32768, &thread, r->sampleRate);
			return gl.t();
		}
		gl.signalError(base::strs("file not found or file format not supported: ", fname->s));
		return gl.nil();
	}
	gl.signalError("playback-set-file: invalid arguments, expected (string)");
	return gl.nil();
}

// playback-unload-file
base::cell_t unload_file(base::lisp &gl, base::cell_t, base::cells_t &) {
	ts.stop();
	ts.setSource(nullptr);
	frs = nullptr;
//.........这里部分代码省略.........
开发者ID:c41x,项目名称:Kiwano,代码行数:101,代码来源:playback.hpp

示例13: changeListenerCallback

 void changeListenerCallback(void *something){
   printf("Some audio change thing.\n");
   if(audioDeviceManager.getCurrentAudioDevice()!=NULL){
     samplerate=audioDeviceManager.getCurrentAudioDevice()->getCurrentSampleRate();
     propertiesfile->setValue("audiodevicemanager",audioDeviceManager.createStateXml());
   }else{
     fprintf(stderr,"Gakkegakke\n");
   }
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例14: play

  void play(){
    int num_channels=getSourceNumChannels();

    if(isinitialized==false || num_channels==0)
      return;

    if(isusingjack==false && audioDeviceManager.getCurrentAudioDevice()==NULL)
      return;

    stop();

    GUI_newprocess(source_init);
    //source_init();
    //fprintf(stderr,"GUI_newprocess finished\n");

#if 0      
    if(isusingjack==false){
      if(audioDeviceManager.getOutputChannels().countNumberOfSetBits()!=getSourceNumChannels()){
	if(num_channels==1)
	  num_channels=2;
	outchannels=new BitArray(0);
	for(int lokke=0;lokke<num_channels;lokke++)
	  outchannels->setBit(lokke);
	audioDeviceManager.setAudioDevice(
					  audioDeviceManager.getAvailableAudioDeviceNames()[0],
					  1024,
					  R,
					  new BitArray(0),
					  outchannels,
					false);
      }
    }
#endif  

    {
      int error;
      for(int i=0;i<num_src_states;i++)
	src_delete(src_states[i]);
      free(src_states);
      
      src_states=(SRC_STATE**)malloc(sizeof(SRC_STATE*)*num_channels);
      
      for(int ch=0;ch<num_channels;ch++)
	src_states[ch]=src_new(SRC_QUALITY,1,&error);
    }

    pleasestop=false;
    jp_playpos=0;
    mustrunonemore=false;
    jp_isplaying=true;
    isreadingdata=true;
  }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例15: init

void init(base::lisp &gl) {
	fm.registerBasicFormats();
	thread.startThread(3);
	dm.addAudioCallback(&asp);
	asp.setSource(&ts);
	pl = new playbackListener(gl);
	ts.addChangeListener(pl);
}
开发者ID:c41x,项目名称:Kiwano,代码行数:8,代码来源:playback.hpp


注:本文中的AudioDeviceManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。