Ejemplo n.º 1
0
 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");
   }
 }
Ejemplo n.º 2
0
  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;
  }
Ejemplo n.º 3
0
  void prefs(){
      
    if(isusingjack==true){
      printerror("Can not change audio when using jack.");
      return;
    }

    AudioDeviceSelectorComponent audioSettingsComp (audioDeviceManager,
						    0, 0,
						    2, 8,
						    false);
    
    // ...and show it in a DialogWindow...
    audioSettingsComp.setSize (400, 170);
    
    DialogWindow::showModalDialog (T("Audio Settings"),
				   &audioSettingsComp,
				   NULL,Colour((uint8)0xb90,(uint8)0x60,(uint8)0x60,(uint8)0xd0),true);
    if(audioDeviceManager.getCurrentAudioDevice()==NULL && isreadingdata==true){
      isreadingdata=false;
    }
  }
Ejemplo n.º 4
0
  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);
	
      }
  }
Ejemplo n.º 5
0
//==============================================================================
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;
}