Esempio n. 1
0
AudioPrefsDialog::AudioPrefsDialog(AudioFrame& frame)
: wxDialog(dynamic_cast<wxWindow*>(&frame), ID_AudioPrefsDialog, "Sound Killer Preferences")
, frame(frame)
, cfg(frame.app.config())
{
	pgMan = new wxPropertyGridManager(this, ID_AudioPrefsManager,
		wxDefaultPosition, wxDefaultSize,
		// These and other similar styles are automatically
		// passed to the embedded wxPropertyGrid.
		wxPG_BOLD_MODIFIED | wxPG_SPLITTER_AUTO_CENTER |
		// Include toolbar.
			wxPG_TOOLBAR |
			// Include description box.
			wxPG_DESCRIPTION | wxPG_NO_INTERNAL_BORDER |
			// Plus defaults.
			wxPGMAN_DEFAULT_STYLE);

	wxPropertyGridPage* page;

	pages.push_back((page = pgMan->AddPage("Sound System")));

//	SoundIo* sio = nullptr;
//	SoundIoDevice* dev = nullptr;
//	SoundIoOutStream* out = nullptr;

	wxArrayString items;
	for(int i = 0; i < soundio_backend_count(0); ++i)
		items.Add(soundio_backend_name(SoundIoBackend(i)));

	page->Append(new wxPropertyCategory("Sound System"));
	page->Append(new wxEnumProperty("Backend", "soundio.backend", items));
	cfg.set("wx.soundio.backend.type", "str");
	cfg.set("wx.soundio.backend.link", "soundio.device");
	items.Clear();
	page->Append(new wxEnumProperty("Device", "soundio.device", items));

//	page->Append(new wxPropertyCategory("Interface"));
//	page->Append(new wxIntProperty("Number2", wxPG_LABEL, 1));
//	page->Append(new wxColourProperty("Colour2", wxPG_LABEL, *wxWHITE) );

	pages.push_back((page = pgMan->AddPage("Plugins")));

	page->Append(new wxBoolProperty("Enable LV2 Plugins", "slv2.enable", false));

	pages.push_back((page = pgMan->AddPage("User Interface")));

	page->Append(new wxFontProperty("Font", wxPG_LABEL));
	// Display a header above the grid
//	pgMan->ShowHeader();
	load();
}
Esempio n. 2
0
AudioSoundIo::setupWidget::setupWidget( QWidget * _parent ) :
	AudioDeviceSetupWidget( AudioSoundIo::name(), _parent )
{
	m_setupUtil.m_setupWidget = this;

	m_backend = new ComboBox( this, "BACKEND" );
	m_backend->setGeometry( 64, 15, 260, 20 );

	QLabel * backend_lbl = new QLabel( tr( "BACKEND" ), this );
	backend_lbl->setFont( pointSize<7>( backend_lbl->font() ) );
	backend_lbl->move( 8, 18 );

	m_device = new ComboBox( this, "DEVICE" );
	m_device->setGeometry( 64, 35, 260, 20 );

	QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this );
	dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) );
	dev_lbl->move( 8, 38 );

	// Setup models
	m_soundio = soundio_create();
	if (!m_soundio)
	{
		fprintf(stderr, "Unable to initialize soundio: out of memory\n");
		return;
	}
	m_soundio->userdata = this;
	m_soundio->on_backend_disconnect = setupWidgetOnBackendDisconnect;
	m_soundio->on_devices_change = setup_widget_on_devices_change;
	m_soundio->app_name = "LMMS";

	int backendCount = soundio_backend_count(m_soundio);
	for (int i = 0; i < backendCount; i += 1)
	{
		SoundIoBackend backend = soundio_get_backend(m_soundio, i);
		m_backendModel.addItem(soundio_backend_name(backend));
	}

	m_isFirst = true;

	reconnectSoundIo();

	bool ok = connect( &m_backendModel, SIGNAL( dataChanged() ), &m_setupUtil, SLOT( reconnectSoundIo() ) );
	assert(ok);

	m_backend->setModel( &m_backendModel );
	m_device->setModel( &m_deviceModel );
}
Esempio n. 3
0
AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) :
	AudioDevice( tLimit<ch_cnt_t>(
		ConfigManager::inst()->value( "audiosoundio", "channels" ).toInt(), DEFAULT_CHANNELS, SURROUND_CHANNELS ),
								_mixer )
{
	outSuccessful = false;
	m_soundio = NULL;
	m_outstream = NULL;
	m_disconnectErr = 0;
	m_outBufFrameIndex = 0;
	m_outBufFramesTotal = 0;

	m_soundio = soundio_create();
	if (!m_soundio)
	{
		fprintf(stderr, "Unable to initialize soundio: out of memory\n");
		return;
	}

	m_soundio->app_name = "LMMS";
	m_soundio->userdata = this;
	m_soundio->on_backend_disconnect = staticOnBackendDisconnect;

	const QString& configBackend = ConfigManager::inst()->value( "audiosoundio", "backend" );
	const QString& configDeviceId = ConfigManager::inst()->value( "audiosoundio", "out_device_id" );
	const QString& configDeviceRaw = ConfigManager::inst()->value( "audiosoundio", "out_device_raw" );

	int err;
	int outDeviceCount = 0;
	int backendCount = soundio_backend_count(m_soundio);
	for (int i = 0; i < backendCount; i += 1)
	{
		SoundIoBackend backend = soundio_get_backend(m_soundio, i);
		if (configBackend == soundio_backend_name(backend))
		{
			if ((err = soundio_connect_backend(m_soundio, backend)))
			{
				// error occurred, leave outDeviceCount 0
			}
			else
			{
				soundio_flush_events(m_soundio);
				if (m_disconnectErr)
				{
					fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(m_disconnectErr));
					return;
				}
				outDeviceCount = soundio_output_device_count(m_soundio);
			}
			break;
		}
	}

	if (outDeviceCount <= 0)
	{
		// try connecting to the default backend
		if ((err = soundio_connect(m_soundio)))
		{
			fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(err));
			return;
		}

		soundio_flush_events(m_soundio);
		if (m_disconnectErr)
		{
			fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(m_disconnectErr));
			return;
		}

		outDeviceCount = soundio_output_device_count(m_soundio);

		if (outDeviceCount <= 0)
		{
			fprintf(stderr, "Unable to initialize soundio: no devices found\n");
			return;
		}
	}

	int selected_device_index = soundio_default_output_device_index(m_soundio);

	bool wantRaw = (configDeviceRaw == "yes");
	for (int i = 0; i < outDeviceCount; i += 1)
	{
		SoundIoDevice *device = soundio_get_output_device(m_soundio, i);
		bool isThisOne = (configDeviceId == device->id && wantRaw == device->is_raw);
		soundio_device_unref(device);
		if (isThisOne)
		{
			selected_device_index = i;
			break;
		}
	}

	SoundIoDevice *device = soundio_get_output_device(m_soundio, selected_device_index);
	m_outstream = soundio_outstream_create(device);
	soundio_device_unref(device);

	if (!m_outstream)
	{
		fprintf(stderr, "Unable to initialize soundio: out of memory\n");
		return;
	}

	int currentSampleRate = sampleRate();
	int closestSupportedSampleRate = -1;

	for (int i = 0; i < device->sample_rate_count; i += 1)
	{
		SoundIoSampleRateRange *range = &device->sample_rates[i];
		if (range->min <= currentSampleRate && currentSampleRate <= range->max)
		{
			closestSupportedSampleRate = currentSampleRate;
			break;
		}
		if (closestSupportedSampleRate == -1 ||
			abs(range->max - currentSampleRate) < abs(closestSupportedSampleRate - currentSampleRate))
		{
			closestSupportedSampleRate = range->max;
		}
	}

	if (closestSupportedSampleRate != currentSampleRate)
	{
		setSampleRate(closestSupportedSampleRate);
		currentSampleRate = closestSupportedSampleRate;
	}

	m_outstream->name = "LMMS";
	m_outstream->software_latency = (double)mixer()->framesPerPeriod() / (double)currentSampleRate;
	m_outstream->userdata = this;
	m_outstream->write_callback = staticWriteCallback;
	m_outstream->error_callback = staticErrorCallback;
	m_outstream->underflow_callback = staticUnderflowCallback;
	m_outstream->sample_rate = currentSampleRate;
	m_outstream->layout = *soundio_channel_layout_get_default(channels());
	m_outstream->format = SoundIoFormatFloat32NE;

	if ((err = soundio_outstream_open(m_outstream)))
	{
		fprintf(stderr, "Unable to initialize soundio: %s\n", soundio_strerror(err));
		return;
	}

	fprintf(stderr, "Output device: '%s' backend: '%s'\n",
			device->name, soundio_backend_name(m_soundio->current_backend));

	outSuccessful = true;
}