Ejemplo n.º 1
0
BASS_DEVICEINFO * bmx_bass_getdeviceinfo(int device) {
	BASS_DEVICEINFO * info = new BASS_DEVICEINFO;
	BOOL success = BASS_GetDeviceInfo(device, info);
	if (!success || (!info->flags & BASS_DEVICE_ENABLED)) {
		delete info;
		return 0;
	}
	return info;
}
Ejemplo n.º 2
0
QHash<QString, QVariant> BassPlayer::outputDeviceList() {
    QHash<QString, QVariant> res;

    BASS_DEVICEINFO info;
    for (int a = 1; BASS_GetDeviceInfo(a, &info); a++) // 0 - no sound
        if ((info.flags & BASS_DEVICE_ENABLED)) {
            QString name = QString(info.name);

            if (info.flags & BASS_DEVICE_DEFAULT) {
                default_device = a;
                name.prepend('*');
            }

            res.insert(name, a);
        }

    #ifdef Q_OS_MAC
        for (int a = 0; BASS_GetDeviceInfo(a | BASS_DEVICES_AIRPLAY, &info); a++)
            res.insert(QString(info.name), a | BASS_DEVICES_AIRPLAY);
    #endif

    return res;
}
Ejemplo n.º 3
0
void main()
{
	BASS_DEVICEINFO di;
	int a;
	printf("Output Devices\n");
	for (a=1;BASS_GetDeviceInfo(a,&di);a++) {
		printf("%d: ",a);
		DisplayDeviceInfo(&di);
	}
	printf("\nInput Devices\n");
	for (a=0;BASS_RecordGetDeviceInfo(a,&di);a++) {
		printf("%d: ",a);
		DisplayDeviceInfo(&di);
	}
}
Ejemplo n.º 4
0
XAudPlayer::XAudPlayer()
{
   m_stream = NULL;

#ifdef DEBUG_NO_SOUND
   return;
#endif

   if (!bass_init)
   {
      int DSidx;
      const HRESULT hr = GetRegInt("Player", "SoundDeviceBG", &DSidx);
      if (hr != S_OK)
          DSidx = -1;

      // now match the Direct Sound device with the BASS device (by name)
      int BASSidx = -1;
      if (DSidx != -1)
      {
          DSAudioDevices DSads;
          if (!FAILED(DirectSoundEnumerate(DSEnumCallBack, &DSads)))
          {
              if ((unsigned int)DSidx >= DSads.size() || DSads[DSidx]->guid != NULL) // primary device has guid NULL, so use BASSidx = -1 in that case
              {
                  BASS_DEVICEINFO info;
                  for (int i = 1; BASS_GetDeviceInfo(i, &info); i++) // 0 = no sound/no device
                      if (info.flags & BASS_DEVICE_ENABLED) // device must be enabled
                      if (strcmp(info.name, DSads[DSidx]->description.c_str()) == 0)
                      {
                          BASSidx = i;
                          break;
                      }
              }

              for (size_t i = 0; i < DSads.size(); i++)
                  delete DSads[i];
          }
      }

      if (!BASS_Init(BASSidx, 44100, 0, g_pvp->m_hwnd, NULL)) // note that sample rate is usually ignored and set depending on the input/file automatically
      {
         char bla[128];
         sprintf_s(bla, "BASS music/sound library initialization error %d", BASS_ErrorGetCode());
         MessageBox(g_pvp->m_hwnd, bla, "Error", MB_ICONERROR);
      }
      bass_init = true;
   }
}
Ejemplo n.º 5
0
/**
 * Define device sound
 * @brief PlayerSetting::AddDispositivo
 * @return void
 */
void PlayerSetting::AddDispositivo()
{
    BASS_DEVICEINFO i;
    QString nombre;

    QString nulo(tr("Sin Sonido")); //añadimos nulo
    this->Dispositivo->addItem(nulo);

    #ifdef Q_OS_UNIX
      //  QString def(tr("Defecto")); //en linux añadimos otro el default
      //  this->Dispositivo->addItem(def);
    #endif


 //****************** añadimos las tarjetas de audio *****************************
    for (int c=1;BASS_GetDeviceInfo(c,&i);c++)// device 1 = el primer dispositivo
    {
        if (i.flags&BASS_DEVICE_ENABLED)// enabled, lo añadimos...
                this->Dispositivo->addItem(nombre.fromAscii(i.name));
    }
}
Ejemplo n.º 6
0
void LoadBassLibrary(TCHAR CurrBassPath[MAX_PATH])
{
	hBass = LoadLibrary(CurrBassPath);
	if (hBass != NULL) {
		newBass = (BASS_SetConfig(BASS_CONFIG_DEV_DEFAULT, TRUE) != 0); // will use new "Default" device

		DBVARIANT dbv = { 0 };

		BASS_DEVICEINFO info;
		if (!db_get_ts(NULL, ModuleName, OPT_OUTDEVICE, &dbv))
			for (int i = 1; BASS_GetDeviceInfo(i, &info); i++)
				if (!mir_tstrcmp(dbv.ptszVal, _A2T(info.name)))
					device = i;

		db_free(&dbv);

		sndLimSnd = db_get_b(NULL, ModuleName, OPT_MAXCHAN, MAXCHAN);
		if (sndLimSnd > MAXCHAN)
			sndLimSnd = MAXCHAN;
		
		TimeWrd1 = db_get_w(NULL, ModuleName, OPT_TIME1, 0);
		TimeWrd2 = db_get_w(NULL, ModuleName, OPT_TIME2, 0);
		QuietTime = db_get_b(NULL, ModuleName, OPT_QUIETTIME, 0);
		EnPreview = db_get_b(NULL, ModuleName, OPT_PREVIEW, 0);
		StatMask = db_get_w(NULL, ModuleName, OPT_STATUS, 0x3ff);

		BASS_Init(device, 44100, 0, pcli->hwndContactList, NULL);

		Volume = db_get_b(NULL, ModuleName, OPT_VOLUME, 33);
		BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume * 100);
		hPlaySound = HookEvent(ME_SKIN_PLAYINGSOUND, OnPlaySnd);
		CreateFrame();
	}
	else {
		FreeLibrary(hBass);
		hBass = NULL;
	}
}
Ejemplo n.º 7
0
QJsonArray KNMusicBackendBass::deviceList()
{
    //Prepare the json array.
    QJsonArray deviceInfoList;
    //Prepare the device object.
    QJsonObject deviceObject;
    //Set the type of device object.
    deviceObject.insert("Type", "CustomObject");
    //Set Add the default output device.
    deviceObject.insert("Name", "");
    deviceObject.insert("Id", "-1");
    deviceInfoList.append(deviceObject);
#ifdef Q_OS_WIN64
    //For 64-bit Windows, we will enable WASAPI as the playing API instead
    //of using DirectX.
    //Find the output device.
    BASS_WASAPI_DEVICEINFO wasapiDeviceInfo;
    for(int deviceIndex=0;
        BASS_WASAPI_GetDeviceInfo(deviceIndex, &wasapiDeviceInfo);
        ++deviceIndex)
    {
        //Check the device flag.
        if(wasapiDeviceInfo.flags & BASS_DEVICE_INPUT)
        {
            //Ignore all the input flags.
            continue;
        }
        //Check the device exclusive mode.
        if(wasapiDeviceInfo.flags & BASS_WASAPI_EXCLUSIVE)
        {
            //Add the device to list.
            deviceObject.insert("Id", "w"+QString::number(deviceIndex));
            //Set the name of the device.
            QString deviceName=wasapiDeviceInfo.name;
            deviceObject.insert("Name", "WASAPI: "+deviceName);
            //Add the device to the list.
            deviceInfoList.append(deviceObject);
        }
    }
#endif
    //Loop and fetch the device info.
    BASS_DEVICEINFO deviceInfo;
    for(DWORD deviceIndex=0;
        BASS_GetDeviceInfo(deviceIndex, &deviceInfo);
        ++deviceIndex)
    {
        //Insert the data.
        deviceObject.insert("Id", QString::number((int)deviceIndex));
        //Get the device name and driver name.
        QString deviceName=deviceInfo.name, driverName=deviceInfo.driver;
        if(!driverName.isEmpty())
        {
            //Append the driver name at the end of the device name.
            deviceName.append(" (" + driverName + ")");
        }
        //Save the device name.
        deviceObject.insert("Name", deviceName);
        //Append the object to list.
        deviceInfoList.append(deviceObject);
    }
    //Give back the device list.
    return deviceInfoList;
}
Ejemplo n.º 8
0
INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			SYSTEMTIME systime = { 0 };

			SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_RESETCONTENT, 0, 0);
			for (int i = 1; i <= MAXCHAN; i++)
				SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_ADDSTRING, 0, (LPARAM)_itot(i, tmp, 10));

			SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_SETCURSEL, sndLimSnd - 1, 0);

			SetDlgItemText(hwndDlg, IDC_CURRPATH, CurrBassPath);

			hwndOptSlider = GetDlgItem(hwndDlg, IDC_VOLUME);
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETRANGE, FALSE, MAKELONG(SLIDER_MIN, SLIDER_MAX));
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPOS, TRUE, Volume);
			SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_SETPAGESIZE, 0, 5);

			systime.wHour = HIBYTE(TimeWrd1);
			systime.wMinute = LOBYTE(TimeWrd1);
			systime.wYear = 2000;
			systime.wMonth = 1;
			systime.wDay = 1;
			SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_SETFORMAT, 0, (LPARAM)_T("HH:mm"));
			SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&systime);
			systime.wHour = HIBYTE(TimeWrd2);
			systime.wMinute = LOBYTE(TimeWrd2);
			SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETFORMAT, 0, (LPARAM)_T("HH:mm"));
			SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM)&systime);

			CheckDlgButton(hwndDlg, IDC_PREVIEW, EnPreview ? BST_CHECKED : BST_UNCHECKED);

			for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
				if (StatMask & (1 << (i - IDC_CHECKBOX1)))
					CheckDlgButton(hwndDlg, i, BST_CHECKED);

			if (QuietTime) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), TRUE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), TRUE);
				CheckDlgButton(hwndDlg, IDC_QUIETTIME, BST_CHECKED);
			}

			if (hBass == NULL) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_VOLUME), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_MAXCHANNEL), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_OUTDEVICE), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_QUIETTIME), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), FALSE);

				for (int i = IDC_CHECKBOX1; i < IDC_CHECKBOX10 + 1; i++)
					EnableWindow(GetDlgItem(hwndDlg, i), FALSE);
			}
			else {
				DBVARIANT dbv = { 0 }; BASS_DEVICEINFO info; DWORD bassver = BASS_GetVersion();

				mir_sntprintf(tmp, _countof(tmp), TranslateT("un4seen's bass version: %d.%d.%d.%d"), bassver >> 24, (bassver >> 16) & 0xff, (bassver >> 8) & 0xff, bassver & 0xff);
				SetDlgItemText(hwndDlg, IDC_BASSVERSION, tmp);

				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_RESETCONTENT, 0, 0);
				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, (LPARAM)TranslateT("--default device--"));
				SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, 0, 0);
				db_get_ts(NULL, ModuleName, OPT_OUTDEVICE, &dbv);
				for (int i = 1; BASS_GetDeviceInfo(i + newBass, &info); i++) {
					SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_ADDSTRING, 0, _A2T(info.name));
					if (!mir_tstrcmp(dbv.ptszVal, _A2T(info.name)))
						SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_SETCURSEL, i, 0);
				}
				db_free(&dbv);
			}
		}
		return TRUE;

	case WM_HSCROLL:
		if (hBass != NULL)
			if (LOWORD(wParam) == SB_ENDSCROLL || LOWORD(wParam) == SB_THUMBTRACK) {
				Volume = SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
				BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume * 100);
				SendMessage(hwndSlider, TBM_SETPOS, TRUE, Volume);
				Preview = TRUE;
				if (EnPreview)
					SkinPlaySound("AlertMsg");
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_APPLY:
			if (hBass != NULL) {
				SYSTEMTIME systime = { 0 };

				GetDlgItemText(hwndDlg, IDC_OUTDEVICE, tmp, _countof(tmp));
				db_set_ts(NULL, ModuleName, OPT_OUTDEVICE, tmp);

				Volume = (DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME, TBM_GETPOS, 0, 0);
				db_set_b(NULL, ModuleName, OPT_VOLUME, Volume);

				sndLimSnd = SendDlgItemMessage(hwndDlg, IDC_MAXCHANNEL, CB_GETCURSEL, 0, 0) + 1;
				if (sndLimSnd > MAXCHAN)
					sndLimSnd = MAXCHAN;
				db_set_b(NULL, ModuleName, OPT_MAXCHAN, sndLimSnd);

				QuietTime = IsDlgButtonChecked(hwndDlg, IDC_QUIETTIME) == BST_CHECKED;
				db_set_b(NULL, ModuleName, OPT_QUIETTIME, QuietTime);

				SendDlgItemMessage(hwndDlg, IDC_TIME1, DTM_GETSYSTEMTIME, 0, (LPARAM)&systime);
				TimeWrd1 = MAKEWORD(systime.wMinute, systime.wHour);
				db_set_w(NULL, ModuleName, OPT_TIME1, TimeWrd1);

				SendDlgItemMessage(hwndDlg, IDC_TIME2, DTM_GETSYSTEMTIME, 0, (LPARAM)&systime);
				TimeWrd2 = MAKEWORD(systime.wMinute, systime.wHour);
				db_set_w(NULL, ModuleName, OPT_TIME2, TimeWrd2);

				EnPreview = IsDlgButtonChecked(hwndDlg, IDC_PREVIEW) == BST_CHECKED;
				db_set_b(NULL, ModuleName, OPT_PREVIEW, EnPreview);

				StatMask = 0;
				for (int i = IDC_CHECKBOX10; i > IDC_CHECKBOX1 - 1; i--) {
					StatMask <<= 1;
					if (IsDlgButtonChecked(hwndDlg, i) == BST_CHECKED)
						StatMask |= 1;
				}

				db_set_w(NULL, ModuleName, OPT_STATUS, StatMask);

				device = SendDlgItemMessage(hwndDlg, IDC_OUTDEVICE, CB_GETCURSEL, 0, 0);
				if (device == 0)
					device = -1;
				else
					device += newBass;
			}
			return 1;

		case PSN_RESET:
			if (hBass != NULL)
				BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume * 100);
			return 1;

		case DTN_DATETIMECHANGE:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			return 1;
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_QUIETTIME:
			{
				BOOL b = IsDlgButtonChecked(hwndDlg, IDC_QUIETTIME) == BST_CHECKED;
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME1), b);
				EnableWindow(GetDlgItem(hwndDlg, IDC_TIME2), b);
			}
		case IDC_MAXCHANNEL:
		case IDC_OUTDEVICE:
		case IDC_CHECKBOX1:
		case IDC_CHECKBOX2:
		case IDC_CHECKBOX3:
		case IDC_CHECKBOX4:
		case IDC_CHECKBOX5:
		case IDC_CHECKBOX6:
		case IDC_CHECKBOX7:
		case IDC_CHECKBOX8:
		case IDC_CHECKBOX9:
		case IDC_CHECKBOX10:
		case IDC_PREVIEW:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_GETBASS:
			Utils_OpenUrl("http://www.un4seen.com/");
			break;
		}
		break;
	}
	return 0;
}
Ejemplo n.º 9
0
SettingsTab::SettingsTab(IPlugin *parent) : QWidget(0), plugin(parent)
{
    QFormLayout *layout = new QFormLayout;
    this->setLayout(layout);

    recDevBox = new QComboBox(this);
    recDevBox->setEditable(true);
    recDevBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    BASS_DEVICEINFO info;
    for (int i=0; BASS_RecordGetDeviceInfo(i, &info); i++)
        recDevBox->addItem(info.name);

    layout->addRow(tr("Audio device: "), recDevBox);

    shoutcastBox = new QGroupBox(tr("SHOUTcast"), this);
    shoutcastBox->setCheckable(true);
    QFormLayout *shoutcastBoxLayout = new QFormLayout;
    shoutcastBox->setLayout(shoutcastBoxLayout);

    sc_version = new QComboBox(this);
    sc_version->addItem("SHOUTcast v1", 1);
    sc_version->addItem("SHOUTcast v2", 2);
    connect(sc_version, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SettingsTab::sc_versionChanged);
    shoutcastBoxLayout->addRow(tr("Version: "), sc_version);

    sc_url = new QLineEdit(this);
    shoutcastBoxLayout->addRow(tr("Server URL: "), sc_url);

    sc_port = new QLineEdit(this);
    sc_port->setValidator(new QIntValidator(0, 65535));
    shoutcastBoxLayout->addRow(tr("Server port: "), sc_port);

    sc_streamid = new QLineEdit(this);
    sc_streamid->setValidator(new QIntValidator(1, 2147483647));
    shoutcastBoxLayout->addRow(tr("Stream ID: "), sc_streamid);

    sc_username = new QLineEdit(this);
    shoutcastBoxLayout->addRow(tr("Username: "******"Password: "******"1 (Mono)"), 1);
    sc_channels->addItem(tr("2 (Stereo)"), 2);
    shoutcastBoxLayout->addRow(tr("Number of channels: "), sc_channels);

    sc_bitrate = new QComboBox(this);
    QList<int> values;
    values << 32 << 40 << 48 << 56 << 64 << 80 << 96 << 112 << 128 << 160 << 192 << 224 << 256 << 320;
    for(int i=0; i<values.size(); i++)
        sc_bitrate->addItem(QString("%1 kbit/s").arg(values[i]), values[i]);

    shoutcastBoxLayout->addRow(tr("Bitrate: "), sc_bitrate);

    sc_sampleRate = new QComboBox(this);
    values.clear();
    values << 32000 << 44100 << 48000;
    for(int i=0; i<values.size(); i++)
        sc_sampleRate->addItem(QString("%1 Hz").arg(values[i]), values[i]);
    shoutcastBoxLayout->addRow(tr("Sample rate: "), sc_sampleRate);

    layout->addRow(shoutcastBox);


    voipBox = new QGroupBox(tr("VoIP (ipfon.pl)"), this);
    voipBox->setCheckable(true);
    QFormLayout *voipBoxLayout = new QFormLayout;
    voipBox->setLayout(voipBoxLayout);

    QHBoxLayout *voip_usernameLayout = new QHBoxLayout;
    QLabel *voip_usernamePrefix = new QLabel("sip:", this);
    voip_usernameLayout->addWidget(voip_usernamePrefix);
    voip_username = new QLineEdit(this);
    voip_usernameLayout->addWidget(voip_username);
    QLabel *voip_usernameSuffix = new QLabel("@sip.ipfon.pl", this);
    voip_usernameLayout->addWidget(voip_usernameSuffix);
    voipBoxLayout->addRow(tr("Username: "******"Password: "******"SIP port: "), voip_port);

    voip_number = new QLineEdit(this);
    voip_number->setValidator(new QIntValidator(0, 999999999));
    voipBoxLayout->addRow(tr("Phone number: "), voip_number);

    voip_pin = new QLineEdit(this);
    voip_pin->setValidator(new QIntValidator(0, 9999));
    voip_pin->setEchoMode(QLineEdit::Password);
    voipBoxLayout->addRow(tr("PIN: "), voip_pin);

    voip_playDev = new QComboBox(this);
    voip_playDev->setEditable(true);
    voip_playDev->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    voip_playDev->addItem(tr("Mute"));

    for (int i=1; BASS_GetDeviceInfo(i, &info); i++)
        voip_playDev->addItem(info.name);

    voipBoxLayout->addRow(tr("Play device: "), voip_playDev);

    layout->addRow(voipBox);
}