Esempio n. 1
0
int getMicrophoneDevice()
{
    BASS_DEVICEINFO info;
    int device = -1;
    for (int a = 0; BASS_RecordGetDeviceInfo(a, &info); a++)
    {
        if ((info.flags&BASS_DEVICE_ENABLED) && (info.flags&BASS_DEVICE_TYPE_MASK) == BASS_DEVICE_TYPE_MICROPHONE)
        {
            device = a;
            break;
        }
    }
    return device;
}
Esempio n. 2
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);
	}
}
Esempio n. 3
0
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
					UnicodeString temp_tone[12]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","H"};
					for(int i=0;i<10;i++)
					{

						for(int j=0;j<12;j++)
						{
							unsigned char temp_str[20]={0};
							tone_mass[i*12+j]=temp_tone[j]+itoa(i,temp_str,10);
						}
					}
					/*int cc=0;
					for(float i=1;cc<10;i/=2)
					{
						octav_mass[cc]=(27.5*(pow(2.0,((float)i/12.0))));
						cc++;
					} */

					for(int i=0;i<111;i++)
					{
						octav_mass[i+9]=(27.5*(pow(2.0,((float)i/12.0))));
					}

                    int c,def;
                    BASS_DEVICEINFO di;
					for (c=0;BASS_RecordGetDeviceInfo(c,&di);c++) {
                        //MESS(16,CB_ADDSTRING,0,di.name);
						if (di.flags&BASS_DEVICE_DEFAULT) { // got the default device
                            //MESS(16,CB_SETCURSEL,c,0);
							def=c;
						}
					}
					InitDevice(def); // initialize default recording
					//StartRecording();
					//Sleep(100);


}
Esempio n. 4
0
INT_PTR CALLBACK dialogproc(HWND h,UINT m,WPARAM w,LPARAM l)
{
	switch (m) {
		case WM_TIMER:
			{ // update the recording/playback counter
				char text[30]="";
				if (rchan) // recording
					sprintf(text,"%d",reclen-44);
				else if (chan) {
					if (BASS_ChannelIsActive(chan)) // playing
						sprintf(text,"%I64d / %I64d",BASS_ChannelGetPosition(chan,BASS_POS_BYTE),BASS_ChannelGetLength(chan,BASS_POS_BYTE));
					else
						sprintf(text,"%I64d",BASS_ChannelGetLength(chan,BASS_POS_BYTE));
				}
				MESS(20,WM_SETTEXT,0,text);
			}
			break;

		case WM_COMMAND:
			switch (LOWORD(w)) {
				case IDCANCEL:
					DestroyWindow(h);
					break;
				case 10:
					if (!rchan)
						StartRecording();
					else
						StopRecording();
					break;
				case 11:
					BASS_ChannelPlay(chan,TRUE); // play the recorded data
					break;
				case 12:
					WriteToDisk();
					break;
				case 13:
					if (HIWORD(w)==CBN_SELCHANGE) { // input selection changed
						int i;
						input=MESS(13,CB_GETCURSEL,0,0); // get the selection
						// enable the selected input
						for (i=0;BASS_RecordSetInput(i,BASS_INPUT_OFF,-1);i++) ; // 1st disable all inputs, then...
						BASS_RecordSetInput(input,BASS_INPUT_ON,-1); // enable the selected
						UpdateInputInfo();
					}
					break;
				case 16:
					if (HIWORD(w)==CBN_SELCHANGE) { // device selection changed
						int i=MESS(16,CB_GETCURSEL,0,0); // get the selection
						// initialize the selected device
						if (InitDevice(i)) {
							if (rchan) { // continue recording on the new device...
								HRECORD newrchan=BASS_RecordStart(FREQ,CHANS,0,RecordingCallback,0);
								if (!newrchan)
									Error("Couldn't start recording");
								else
									rchan=newrchan;
							}
						}
					}
					break;
			}
			break;

		case WM_HSCROLL:
			if (l) { // set input source level
				float level=SendMessage((HWND)l,TBM_GETPOS,0,0)/100.f;
				if (!BASS_RecordSetInput(input,0,level)) // failed to set input level
					BASS_RecordSetInput(-1,0,level); // try master level instead
			}
			break;

		case WM_INITDIALOG:
			win=h;
			MESS(14,TBM_SETRANGE,FALSE,MAKELONG(0,100));
			{ // get list of recording devices
				int c,def;
				BASS_DEVICEINFO di;
				for (c=0;BASS_RecordGetDeviceInfo(c,&di);c++) {
					MESS(16,CB_ADDSTRING,0,di.name);
					if (di.flags&BASS_DEVICE_DEFAULT) { // got the default device
						MESS(16,CB_SETCURSEL,c,0);
						def=c;
					}
				}
				InitDevice(def); // initialize default recording device
			}
			SetTimer(h,0,200,0); // timer to update the position display
			return 1;

		case WM_DESTROY:
			// release all BASS stuff
			BASS_RecordFree();
			BASS_Free();
			break;
	}
	return 0;
}
Esempio n. 5
0
int main(int argc, char **argv)
{
    std::cerr << "Start\n";

    HANDLE hMapFile = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "sc_shared");

    if(hMapFile == NULL)
    {
        return -10;
    }

    Shared *shared;

    shared = (Shared*)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*shared));

    if(shared == NULL)
    {
        return -11;
    }

    std::string recDev = getopt(argc, argv, "--recDev=");
    //int sc_version = std::stoi(getopt(argc, argv, "--version="));

    BASS_SetConfig(BASS_CONFIG_UNICODE, true);

    int recDevNo = -1;

    BASS_DEVICEINFO info;

    for(int i=0; BASS_RecordGetDeviceInfo(i, &info); i++)
    {
        if(recDev == std::to_string(hash_str(info.name)))
        {
            recDevNo = i;
            break;
        }
    }

    if(!BASS_RecordInit(recDevNo))
    {
        int code = BASS_ErrorGetCode();
        std::string text = "BASS error: " + std::to_string(code);

        if(code == 23)
            text += "\nProblem with device: \"" + recDev + "\"!";

        std::cerr << text << "\n";

        return -1;
    }

    int sampleRate = std::stoi(getopt(argc, argv, "--samplerate="));
    int channels = std::stoi(getopt(argc, argv, "--channels="));

    recStream = BASS_RecordStart(sampleRate, channels, 0, RecordProc, nullptr);

#ifdef _WIN32
    std::string lameBin = "lame.exe";
#else
    std::string lameBin = "lame";
#endif

    HENCODE encoder = BASS_Encode_Start(recStream,
                                        (lameBin + " -b " + getopt(argc, argv, "--bitrate=") + " -").c_str(),
                                        0,
                                        NULL,
                                        0);

    bool ok = BASS_Encode_CastInit(encoder,
                         getopt(argc, argv, "--url=").c_str(),
                         getopt(argc, argv, "--password="******"--bitrate=")),
                         FALSE);

    if(!ok)
    {
        int code = BASS_ErrorGetCode();
        std::string text = "BASS error: " + std::to_string(code);

        std::cerr << text << "\n";

        return -2;
    }

    std::cerr << "OK\n";

    while(!shared->end)
    {
        if(BASS_Encode_IsActive(encoder) != BASS_ACTIVE_PLAYING)
        {
            return -3;
        }

        BASS_CHANNELINFO info;

        if(BASS_ChannelGetInfo(recStream, &info))
        {
            DWORD flags = info.chans == 1 ? BASS_LEVEL_MONO : BASS_LEVEL_STEREO;
            BASS_ChannelGetLevelEx(recStream, shared->levels, 0.035f, flags);
        }

        Sleep(35);
    }

    std::cerr << "End\n";

    UnmapViewOfFile((LPCVOID)shared);
    CloseHandle(hMapFile);

    return 0;
}
Esempio n. 6
0
SettingsTab::SettingsTab(IPlugin *parent) : QWidget(0), plugin(parent)
{
    QFormLayout *layout = new QFormLayout;
    this->setLayout(layout);

    QHBoxLayout *dirLayout = new QHBoxLayout;

    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);

    recsDir = new QLineEdit(this);
    dirLayout->addWidget(recsDir);

    QPushButton *recsDirBtn = new QPushButton(QApplication::style()->standardIcon(QStyle::SP_DirIcon), "", this);
    recsDirBtn->setToolTip(tr("Select directory"));
    connect(recsDirBtn, &QPushButton::clicked, this, &SettingsTab::recsDirBtn_clicked);
    dirLayout->addWidget(recsDirBtn);

    layout->addRow(tr("Recordings directory: "), dirLayout);

    channels = new QComboBox(this);
    channels->addItem(tr("1 (Mono)"), 1);
    channels->addItem(tr("2 (Stereo)"), 2);
    layout->addRow(tr("Number of channels: "), channels);

    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++)
        bitrate->addItem(QString("%1 kbit/s").arg(values[i]), values[i]);

    layout->addRow(tr("Bitrate: "), bitrate);

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

    QVBoxLayout *filenameFmtLayout = new QVBoxLayout;

    filenameFmt = new QComboBox(this);
    filenameFmt->setEditable(true);
    connect(filenameFmt, &QComboBox::currentTextChanged, this, &SettingsTab::filenameFmt_changed);
    filenameFmtLayout->addWidget(filenameFmt);

    filenameExample = new QLabel(this);
    filenameExample->setWordWrap(true);
    filenameFmtLayout->addWidget(filenameExample);

    QLabel *filenameHelp = new QLabel(this);
    filenameHelp->setTextFormat(Qt::RichText);
    filenameHelp->setText(tr("Available tags:<br/>"
                             "<b>%d%</b> - the day (1 to 31)<br/>"
                             "<b>%dd%</b> - the day with a leading zero (01 to 31)<br/>"
                             "<b>%ddd%</b> - the abbreviated day name ('Mon' to 'Sun')<br/>"
                             "<b>%dddd%</b> - the long day name ('Monday' to 'Sunday')<br/>"
                             "<b>%M%</b> - the month (1-12)<br/>"
                             "<b>%MM%</b> - the month with a leading zero (01-12)<br/>"
                             "<b>%MMM%</b> - the abbreviated month name ('Jan' to 'Dec')<br/>"
                             "<b>%MMMM%</b> - the long month name ('January' to 'December')<br/>"
                             "<b>%yy%</b> - the year as two digit number (00-99)<br/>"
                             "<b>%yyyy%</b> - the year as four digit number<br/><br/>"
                             "<b>%h%</b> - the hour (0 to 23 or 1 to 12 if AM/PM display)<br/>"
                             "<b>%hh%</b> - the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)<br/>"
                             "<b>%H%</b> - the hour (0 to 23, even with AM/PM display)<br/>"
                             "<b>%HH%</b> - the hour with a leading zero (00 to 23, even with AM/PM display)<br/>"
                             "<b>%m%</b> - the minute (0 to 59)<br/>"
                             "<b>%mm%</b> - the minute with a leading zero (00 to 59)<br/>"
                             "<b>%s%</b> - the second (0 to 59)<br/>"
                             "<b>%ss%</b> - the second with a leading zero (00 to 59)<br/>"
                             "<b>%AP%</b> - 'AM' or 'PM'<br/>"
                             "<b>%ap%</b> - 'am' or 'pm'<br/><br/>"
                             "<b>%n%</b> - filename entered by user"));
    filenameFmtLayout->addWidget(filenameHelp);

    layout->addRow(tr("Default filename: "), filenameFmtLayout);
}
Esempio n. 7
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);
}