Ejemplo n.º 1
0
void setup_BASS()
{
  int i;
  if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
    printf("An incorrect version of BASS was loaded");
    return;
  }
  // setup output - default device
  if (!BASS_Init(-1,44100,0,0,NULL))
    exit(0);

    // this could probably be a simple for loop, but can't figure it out yet
    // TODO sprintf can be used to make the filenames in a for loop (if wanted)
    sounds[0] = BASS_StreamCreateFile(FALSE, "./sound/bang6.mp3", 0, 0, 0);
    sounds[1] = BASS_StreamCreateFile(FALSE, "./sound/bang2.mp3", 0, 0, 0);
    sounds[2] = BASS_StreamCreateFile(FALSE, "./sound/bang3.mp3", 0, 0, 0);
    sounds[3] = BASS_StreamCreateFile(FALSE, "./sound/bang0.mp3", 0, 0, 0);
    sounds[4] = BASS_StreamCreateFile(FALSE, "./sound/bang3.mp3", 0, 0, 0);
    sounds[5] = BASS_StreamCreateFile(FALSE, "./sound/bang4.mp3", 0, 0, 0);
    sounds[6] = BASS_StreamCreateFile(FALSE, "./sound/bang6.mp3", 0, 0, 0);
    sounds[7] = BASS_StreamCreateFile(FALSE, "./sound/fizz_out.wav", 0, 0, 0);
    sounds[8] = BASS_StreamCreateFile(FALSE, "./sound/1812.wav", 0, 0, 0);
    sounds[9] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[10] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[11] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[12] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[13] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[14] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    sounds[15] = BASS_StreamCreateFile(FALSE, "./sound/launch8.mp3", 0, 0, 0);
    BASS_ChannelSetAttribute(sounds[7], BASS_ATTRIB_VOL, .2);
}
Ejemplo n.º 2
0
Player::Player(QWidget *parent) :Html5ApplicationViewer(parent) {
    QObject::connect(webView()->page()->mainFrame(),
            SIGNAL(javaScriptWindowObjectCleared()), SLOT(addToJavaScript()));
    api.sync();
    playStatus = false;
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
            return;
    }

    if (!BASS_Init(-1,44100,0,NULL,NULL)) {
            return;
    }
    BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
    BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
    playList.insert("1", "http://mp3.polskieradio.pl:8900/;stream");
    playList.insert("2", "http://stream3.polskieradio.pl:8902/;stream");
    playList.insert("3", "http://stream3.polskieradio.pl:8904/;stream");
    playList.insert("4", "http://mp3.polskieradio.pl:8906/;stream");
    playList.insert("antyradio", "http://ant-waw.cdn.eurozet.pl:8602/;stream");
    acr.loadSettings();
    QObject::connect(&acr, SIGNAL(songFound(QJsonObject)),
                     this, SLOT(songFound(QJsonObject)));
    QObject::connect(&api, SIGNAL(updateReady(QList<Radiostation>)),
                     this, SLOT(songFound(QList<Radiostation>)));
}
Ejemplo n.º 3
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASS wc={0};
    MSG msg;

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
		return 0;
	}

	// register window class and create the window
	wc.lpfnWndProc = SpectrumWindowProc;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.lpszClassName = "BASS-Spectrum";
	if (!RegisterClass(&wc) || !CreateWindow("BASS-Spectrum",
			"BASS \"live\" spectrum (click to toggle mode)",
			WS_POPUPWINDOW|WS_CAPTION|WS_VISIBLE, 200, 200,
			SPECWIDTH+2*GetSystemMetrics(SM_CXDLGFRAME),
			SPECHEIGHT+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYDLGFRAME),
			NULL, NULL, hInstance, NULL)) {
		Error("Can't create window");
		return 0;
	}
	ShowWindow(win, SW_SHOWNORMAL);

	while (GetMessage(&msg,NULL,0,0)>0) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}
Ejemplo n.º 4
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASS wc;
	MSG msg;

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
		return 0;
	}

	// register window class and create the window
	memset(&wc,0,sizeof(wc));
	wc.lpfnWndProc = SpectrumWindowProc;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.lpszClassName = "BASS-CustLoop";
	if (!RegisterClass(&wc) || !CreateWindow("BASS-CustLoop",
			"BASS custom looping example (left-click to set loop start, right-click to set end)",
			WS_POPUPWINDOW|WS_CAPTION|WS_VISIBLE, 100, 100,
			WIDTH+2*GetSystemMetrics(SM_CXDLGFRAME),
			HEIGHT+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYDLGFRAME),
			NULL, NULL, hInstance, NULL)) {
		Error("Can't create window");
		return 0;
	}
	ShowWindow(win, SW_SHOWNORMAL);

	while (GetMessage(&msg,NULL,0,0)>0) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}
Ejemplo n.º 5
0
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH && HIWORD(BASS_GetVersion()) != BASSVERSION) {
		MessageBox(NULL, "Incorrect BASS.DLL version (" BASSVERSIONTEXT " is required)", "ASAP", MB_ICONERROR);
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 6
0
__declspec(dllexport) int __cdecl initBASS() {
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
		return 1;
	}
	HWND mainWindow = FindMyTopMostWindow();
	BASS_Init(-1,44100,0,mainWindow,NULL);
	return 1;
}
Ejemplo n.º 7
0
tag_reader* reader_wma( DWORD handle )
{
	if (HIWORD(BASS_GetVersion())<0x204)
		return new reader( handle );

	return new preproc_reader( 
		BASS_ChannelGetTags( handle, BASS_TAG_WMA ),
		"WMA: bad tag format", remap, SIZE_OF_ARRAY(remap), '=', 0 );
}
Ejemplo n.º 8
0
BassPlayer::BassPlayer(QWidget * parent) : IPlayer(parent), chan(0), openChannelWatcher(0) {
    if (HIWORD(BASS_GetVersion()) != BASSVERSION)
        throw "An incorrect version of BASS.DLL was loaded";

    if (HIWORD(BASS_FX_GetVersion()) != BASSVERSION)
        throw "An incorrect version of BASS_FX.DLL was loaded";

//    BASS_SetVolume(1);
    initOutputDevice(identifyOutputDevice());
    loadPlugins();
    setUserAgent(DEFAULT_AGENT);
}
Ejemplo n.º 9
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
		return 0;
	}

	DialogBox(hInstance,(char*)1000,0,&dialogproc);

	return 0;
}
Ejemplo n.º 10
0
int main(int argc, char* argv[])
{
	regex_t fregex;

	gtk_init(&argc,&argv);

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// enable floating-point DSP (not really necessary as the channels will be floating-point anyway)
	BASS_SetConfig(BASS_CONFIG_FLOATDSP,TRUE);

	// initialize default device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	// initialize GUI
	glade=glade_xml_new(GLADE_PATH"dsptest.glade",NULL,NULL);
	if (!glade) return 0;
	win=GetWidget("window1");
	if (!win) return 0;
	glade_xml_signal_autoconnect(glade);

	{ // initialize file selector
		GtkFileFilter *filter;
		filesel=gtk_file_chooser_dialog_new("Open File",GTK_WINDOW(win),GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"Playable files");
		regcomp(&fregex,"\\.(mo3|xm|mod|s3m|it|umx|mp[1-3]|ogg|wav|aif)$",REG_ICASE|REG_NOSUB|REG_EXTENDED);
		gtk_file_filter_add_custom(filter,GTK_FILE_FILTER_FILENAME,FileExtensionFilter,&fregex,NULL);
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"All files");
		gtk_file_filter_add_pattern(filter,"*");
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
	}

	gtk_main();

	gtk_widget_destroy(filesel);
	regfree(&fregex);

	BASS_Free();

    return 0;
}
Ejemplo n.º 11
0
int main(int argc, char* argv[])
{
	IBNibRef 		nibRef;
	OSStatus		err;
	
	InitCursor();

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS.DLL was loaded (2.4 is required)");
		return 0;
	}

	// check the correct BASS_FX was loaded
	if (HIWORD(BASS_FX_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS_FX.DLL was loaded (2.4 is required)");
		return 0;
	}

	// initialize default output device
	if(!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	// Create Window and Stuff
	err = CreateNibReference(CFSTR("reverse"), &nibRef);
	if (err) return err;
	err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &win);
	if (err) return err;
	DisposeNibReference(nibRef);

	SetupControlHandler(10,kEventControlHit,OpenEventHandler);
	SetControlAction(GetControl(11),NewControlActionUPP(VolEventHandler));
	SetControlAction(GetControl(13),NewControlActionUPP(TempoEventHandler));
	SetControlAction(GetControl(15),NewControlActionUPP(PosEventHandler));
	SetupControlHandler(16,kEventControlHit,DirEventHandler);

	EventLoopTimerRef timer;
	InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/2,TimerProc,0,&timer);

	// The window was created hidden so show it.
	ShowWindow(win);
    
	// Call the event loop
	RunApplicationEventLoop();
   
	// Close output
	BASS_Free();

	return 0;
}
Ejemplo n.º 12
0
/*
	Проверка версии BASS и инициализация устройства
*/
INT Application::CheckedInitBASS()
{
	if (HIWORD(BASS_GetVersion()) != BASSVERSION)
	{
		MessageBox(NULL, TEXT("Ошибка версии BASS."), NULL, 0);
		return 1;
	}
	if (!BASS_Init(-1, 44100, BASS_DEVICE_3D, 0, NULL))
	{
		MessageBox(NULL, TEXT("Не удалось инициализировать BASS."), NULL, 0);
		return 1;
	}
}
Ejemplo n.º 13
0
bool CAudioManager::Initialize()
{
	// Ensure we have a valid BASS version
	if(HIWORD(BASS_GetVersion()) != BASSVERSION)
	{
		CLogFile::Printf("Invalid BASS version");
		return false;
	}

	// Initialize the BASS audio library
	BASS_Init(-1, 44100, 0, 0, NULL);
	return true;
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // check the correct BASS was loaded
    if (HIWORD(BASS_GetVersion()) != BASSVERSION) {
        return 2;
    }

    CMixer *mixer = new CMixer(&a);
    QObject::connect(mixer, SIGNAL(finished()), &a, SLOT(quit()));
    QTimer::singleShot(0, mixer, SLOT(run()));

    return a.exec();
}
Ejemplo n.º 15
0
void net_radio_init(HWND hwnd) {
    // check the correct BASS was loaded
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
        error("An incorrect version of BASS.DLL was loaded");
        return;
    }
    win = hwnd;
    // setup output device
    if (!BASS_Init(-1,44100,0,win,NULL)) {
        error("Can't initialize device");
        DestroyWindow(win);
    }
    BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
    BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
    BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy); // setup proxy server location
}
Ejemplo n.º 16
0
BOOL WINAPI __declspec(dllexport) DllMain(HINSTANCE hDLL, DWORD reason, LPVOID reserved)
{
	switch (reason) {
		case DLL_PROCESS_ATTACH:
			DisableThreadLibraryCalls((HMODULE)hDLL);
			if (HIWORD(BASS_GetVersion())!=BASSVERSION || !GetBassFunc2()) {
				MessageBoxA(0,"Incorrect BASS.DLL version (" BASSVERSIONTEXT " is required)", "BASS", MB_ICONERROR | MB_OK);
				return FALSE;
			}
else {
bassfunc->RegisterPlugin(SetCustFX, PLUGIN_FX_ADD);
}
			break;
}
	return TRUE;
}
Ejemplo n.º 17
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	inst=hInstance;

	// Check that BASS 1.8 was loaded
	if (BASS_GetVersion()!=MAKELONG(1,8)) {
		MessageBox(0,"BASS version 1.8 was not loaded","Incorrect BASS.DLL",0);
		return 0;
	}

	DialogBox(inst,(char*)1000,0,&dialogproc);

	BASS_Free();

	return 0;
}
Ejemplo n.º 18
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
		return 0;
	}

	{ // enable trackbar support (for the level control)
		INITCOMMONCONTROLSEX cc={sizeof(cc),ICC_BAR_CLASSES};
		InitCommonControlsEx(&cc);
	}

	DialogBox(hInstance,(char*)1000,0,&dialogproc);

	return 0;
}
Ejemplo n.º 19
0
int main(int argc, char* argv[])
{
	IBNibRef 		nibRef;
	OSStatus		err;

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize default output device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
	BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
	BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy); // setup proxy server location

	// Create Window and stuff
	err = CreateNibReference(CFSTR("netradio"), &nibRef);
	if (err) return err;
	err = CreateWindowFromNib(nibRef, CFSTR("Window"), &win);
	if (err) return err;
	DisposeNibReference(nibRef);

	int a;
	for (a=10;a<20;a++)
		SetupControlHandler(a,kEventControlHit,RadioEventHandler);
	SetupControlHandler(41,kEventControlHit,DirectEventHandler);
	{
		EventTypeSpec etype={'blah','blah'};
		InstallApplicationEventHandler(NewEventHandlerUPP(CustomEventHandler),1,&etype,NULL,NULL);
	}

	ShowWindow(win);
	RunApplicationEventLoop();

	BASS_Free();

    return 0; 
}
Ejemplo n.º 20
0
HRESULT CBSoundMgr::Initialize()
{
	m_SoundAvailable = false;


#ifdef __IPHONEOS__
	#define BASS_CONFIG_IOS_MIXAUDIO 34
    BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 6);
#endif

	
	if (HIWORD(BASS_GetVersion()) != BASSVERSION)
	{
		Game->LOG(0, "An incorrect version of BASS was loaded");
		return E_FAIL;
	}

#ifdef  USE_BASS_FX
	if (HIWORD(BASS_FX_GetVersion()) != BASSVERSION) 
	{
		Game->LOG(0, "An incorrect version of BASS FX was loaded");
		return E_FAIL;
	} 
#endif

	if (!BASS_Init(-1, 44100, 0, 0, NULL))
	{
		Game->LOG(0, "Can't initialize sound device");
		return E_FAIL;
	}

	m_VolumeMaster = Game->m_Registry->ReadInt("Audio", "MasterVolume", 100);

	m_VolumeSFX    = Game->m_Registry->ReadInt("Audio", "SFXVolume",    100);
	m_VolumeSpeech = Game->m_Registry->ReadInt("Audio", "SpeechVolume", 100);
	m_VolumeMusic  = Game->m_Registry->ReadInt("Audio", "MusicVolume",  100);


	m_SoundAvailable = true;
	SetMasterVolumePercent(m_VolumeMaster);

	return S_OK;
}
Ejemplo n.º 21
0
	CPlayer()
	{
		//return; // multi thread crash

		m_this = this;
		ZeroMemory(fx, sizeof(fx));
		ZeroMemory(vol, sizeof(vol));
		ZeroMemory(pos, sizeof(pos));

		m_fPosition = 0.0f;
		m_fTempo = 120.0f;
		m_bPlaying = false;
		m_fFreqMultiply = 1.0f;
		m_fFreqMultiplyStep = 0.0f;
		// check the correct BASS was loaded
		if (HIWORD(BASS_GetVersion())!=BASSVERSION) 
		{
			printf("An incorrect version of BASS.DLL was loaded");
			return;
		}

		BASS_SetConfig(BASS_CONFIG_VISTA_TRUEPOS,0); // allows lower latency on Vista and newer
		BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD,10); // 10ms update period

		// initialize default output device (and measure latency)
		if (!BASS_Init(-1,44100,BASS_DEVICE_LATENCY,0,NULL))
		{
			printf("Can't initialize device");
			return;
		}			

		BASS_GetInfo(&info);
		BASS_SetConfig(BASS_CONFIG_BUFFER,10+info.minbuf+1); // default buffer size = update period + 'minbuf' + 1ms extra margin
		buflen=BASS_GetConfig(BASS_CONFIG_BUFFER);
		if (!info.freq) info.freq=44100; // if the device's output rate is unknown default to 44100 Hz	
		stream=BASS_StreamCreate(info.freq,2,0,(STREAMPROC*)CPlayer::_WriteStream,0); // create a stream (stereo for effects)
		BASS_ChannelPlay(stream,FALSE); // start it
		//BASS_ChannelSetFX(stream, BASS_FX_DX8_CHORUS, 0);
		//
	}
Ejemplo n.º 22
0
void main(int argc, char **argv)
{
	DWORD chan,act,time,level;
	BOOL ismod;
	QWORD pos;
	int a;

	printf("Simple console mode BASS example : MOD/MPx/OGG/WAV player\n"
			"---------------------------------------------------------\n");

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		printf("An incorrect version of BASS was loaded");
		return;
	}

	if (argc!=2) {
		printf("\tusage: contest <file>\n");
		return;
	}

	// setup output - default device
	if (!BASS_Init(-1,44100,0,0,NULL))
		Error("Can't initialize device");

	// try streaming the file/url
	if ((chan=BASS_StreamCreateFile(FALSE,argv[1],0,0,BASS_SAMPLE_LOOP))
		|| (chan=BASS_StreamCreateURL(argv[1],0,BASS_SAMPLE_LOOP,0,0))) {
		pos=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
		if (BASS_StreamGetFilePosition(chan,BASS_FILEPOS_DOWNLOAD)!=-1) {
			// streaming from the internet
			if (pos!=-1)
#ifdef _WIN32
				printf("streaming internet file [%I64u bytes]",pos);
#else
				printf("streaming internet file [%llu bytes]",pos);
#endif
			else
				printf("streaming internet file");
		} else
Ejemplo n.º 23
0
bool initSoundStuff (HWND hwnd) {
	if (HIWORD(BASS_GetVersion())!=BASSVERSION)
	{
		warning (WARNING_BASS_WRONG_VERSION);
		return false;
	}

	if (!BASS_Init(-1,44100,0,hwnd,NULL)) {
		warning (WARNING_BASS_FAIL);
		return false;
	}

	int a;
	for (a = 0; a < MAX_SAMPLES; a ++) {
		soundCache[a].sample = NULL;
		soundCache[a].fileLoaded = -1;
	}

	BASS_SetConfig(BASS_CONFIG_GVOL_MUSIC, 10000);
	BASS_SetConfig(BASS_CONFIG_GVOL_SAMPLE, 10000);
	BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 10000);
	return soundOK = true;
}
Ejemplo n.º 24
0
int main(int argc, char* argv[])
{
	gtk_init(&argc,&argv);

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize default output device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	// initialize GUI
	glade=glade_xml_new(GLADE_PATH"synth.glade",NULL,NULL);
	if (!glade) return 0;
	win=GetWidget("window1");
	if (!win) return 0;
	glade_xml_signal_autoconnect(glade);

	BASS_GetInfo(&info);
	stream=BASS_StreamCreate(info.freq,2,BASS_SAMPLE_FLOAT,(STREAMPROC*)WriteStream,0); // create a stream (stereo for effects)
	BASS_ChannelSetAttribute(stream,BASS_ATTRIB_NOBUFFER,1); // no buffering for minimum latency
	BASS_ChannelPlay(stream,FALSE); // start it

	g_signal_connect(win,"key-press-event",G_CALLBACK(KeyHandler),NULL);
	g_signal_connect(win,"key-release-event",G_CALLBACK(KeyHandler),NULL);

	gtk_main();

	BASS_Free();

    return 0;
}
Ejemplo n.º 25
0
int main(int argc, char* argv[])
{
	g_thread_init(NULL);
	gdk_threads_init();
	gtk_init(&argc,&argv);

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize default output device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing
	BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead
	BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy); // setup proxy server location

	// initialize GUI
	glade=glade_xml_new(GLADE_PATH"netradio.glade",NULL,NULL);
	if (!glade) return 0;
	win=GetWidget("window1");
	if (!win) return 0;
	glade_xml_signal_autoconnect(glade);

	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();

	BASS_Free();

    return 0;
}
Ejemplo n.º 26
0
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
	inst=hInstance;

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS.DLL was loaded (2.4 is required)","Incorrect BASS.DLL",MB_ICONERROR);
		return 1;
	}

	// check the correct BASS_FX was loaded
	if (HIWORD(BASS_FX_GetVersion())!=BASSVERSION) {
		MessageBox(0,"An incorrect version of BASS_FX.DLL was loaded (2.4 is required)","Incorrect BASS_FX.DLL",MB_ICONERROR);
		return 1;
	}

	DialogBox(inst,(char*)1000,0,&dialogproc);

	BASS_Free();

	DeleteObject(Font);

	return 0;
}
Ejemplo n.º 27
0
PlaybackWidget::PlaybackWidget(QWidget *parent) : QWidget(parent)
{
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
        qDebug() << "Wrong bass version";
    }
    db = &DBI::getInstance();
    //Setup ui
    ui.setupUi(this);
    play = QPixmap(":/imgs/play");
    pause = QPixmap(":/imgs/pause");
    ui.prevBtn->setIcon(QIcon(QPixmap(":/imgs/prev")));
    ui.nextBtn->setIcon(QIcon(QPixmap(":/imgs/next")));
    ui.playBtn->setIcon(QIcon(play));
    connect(ui.playBtn, SIGNAL(released()), SLOT(togglePlay()));
    //Setup Audio output
    if (!BASS_Init(-1,44100,0,0,NULL))
        Error("Can't initialize device");
    curchan = NULL;
    state = STOPPED;
    updateTimer = std::unique_ptr<QTimer>(new QTimer(this));
    connect(updateTimer.get(), SIGNAL(timeout()), SLOT(update()));
    connect(ui.playSlider, SIGNAL(seekTo(float)), SLOT(seek(float)));
    updateTimer->setInterval(50);
}
Ejemplo n.º 28
0
inline bool KNMusicBackendBass::initialBass(DWORD &channelFlags)
{
    //Detect operating system version and enable option for using WASAPI.
#ifdef Q_OS_WIN64
    m_wasapiEnabled=m_systemConfigure->data("WASAPI", false).toBool();
#endif
    //Get the buffer length.
    int bufferLength=m_systemConfigure->data("BufferLength", 500).toInt();
    //Check buffer length is valid.
    if(bufferLength<10)
    {
        //For minimum, buffer should be 10ms.
        bufferLength=10;
    }
    else if(bufferLength>5000)
    {
        //For maximum, buffer should be 5000ms.
        bufferLength=5000;
    }
    //Get the output device index.
    QString outputDeviceId="-1";
    {
        //Check whether the configure has output device.
        if(m_systemConfigure->contains("OutputDevice"))
        {
            //Get the json object.
            QJsonObject deviceInfo=
                    m_systemConfigure->data("OutputDevice").toJsonObject();
            //Get the device info Id.
            outputDeviceId=deviceInfo.value("Id").toString();
        }
    }
    //Check the bass library version first.
    if(HIWORD(BASS_GetVersion()) > BASSVERSION)
    {
        //Failed to load a higher version bass library.
        return false;
    }
    //Enabled float digital signal processing.
    //DON'T MOVE THIS, this should config before bass init.
    if(m_systemConfigure->data("Float", false).toBool())
    {
        //Enable 32-bit floating-point sample data converting.
        BASS_SetConfig(BASS_CONFIG_FLOATDSP, TRUE);
    }
    //Set the buffer length.
    BASS_SetConfig(BASS_CONFIG_BUFFER, static_cast<DWORD>(bufferLength));
    //Get the setting sample rate.
    QString userSampleRate=
            m_systemConfigure->data("SampleRate", "None").toString();
    //Set a default initial sample rate.
    int initialSampleRate=44100;
#ifdef Q_OS_WIN64
    if(m_wasapiEnabled)
    {
        //Prepare the user output device info.
        int userOutputDevice=-1;
        //Check the user output device selection.
        if(outputDeviceId.startsWith("w"))
        {
            //Get the possible output device.
            userOutputDevice=outputDeviceId.mid(1).toInt();
        }
        //For 64-bit Windows, we will enable WASAPI as the playing API instead
        //of using DirectX.
        //Find the output device.
        BASS_WASAPI_DEVICEINFO deviceInfo;
        int deviceCount=0;
        QList<int> validDeviceIndex;
        for(deviceCount=0;
            BASS_WASAPI_GetDeviceInfo(deviceCount, &deviceInfo);
            ++deviceCount)
        {
            //Check the device flag.
            if((deviceInfo.flags & (BASS_DEVICE_LOOPBACK |
                                    BASS_DEVICE_INPUT))==0)
            {
                //Check the valid device list.
                if((deviceInfo.flags & BASS_DEVICE_DEFAULT)
                        ==BASS_DEVICE_DEFAULT)
                {
                    //Save the default device index.
                    m_wasapiOutputDevice=deviceCount;
                }
                //Add the device to the list.
                validDeviceIndex.append(deviceCount);
            }
        }
        // Check the device index.
        if(validDeviceIndex.isEmpty())
        {
            //Failed to find the output device.
            return false;
        }
        //Check the user selection is still valid.
        if(validDeviceIndex.contains(userOutputDevice))
        {
            //Set the user selected device as the output device.
            m_wasapiOutputDevice=userOutputDevice;
        }
        //Because we won't playing anything via BASS, so don't need an update
        //thread.
        BASS_SetConfig(BASS_CONFIG_UPDATETHREADS, 0);
        //Setup BASS - "no sound" device with the "mix" sample rate (default for
        //MOD music)
        BASS_Init(0, deviceInfo.mixfreq, 0, 0, NULL);
    }
    else
    {
#endif
        //Check the start data.
        DWORD outputDevice=-1;
        if(!outputDeviceId.startsWith("w"))
        {
            //Get the raw output device
            int rawOutputDevice=outputDeviceId.toInt();
            //Check whether the output device is valid.
            QJsonArray allDevices=deviceList();
            //Check whether the output device is existed.
            if(rawOutputDevice>=-1 && (rawOutputDevice<allDevices.size()-1))
            {
                //Set the device back to default.
                outputDevice=rawOutputDevice;
            }
        }
        //Normal bass initialize.
        //Prepare the bass initial flag.
        DWORD initFlag=0;
        //Check the user sample rate.
        if(QString::number(userSampleRate.toInt())==userSampleRate)
        {
            //Update the initial sample rate.
            initialSampleRate=userSampleRate.toInt();
            //Add the initial flag.
            initFlag |= BASS_DEVICE_FREQ;
        }
        //Check the preference setting.
        if(m_systemConfigure->data("Stereo", false).toBool())
        {
            //Add stereo flag.
            initFlag |= BASS_DEVICE_STEREO;
        }
        //Initial bass library.
        if(!BASS_Init(outputDevice, initialSampleRate, initFlag, NULL, NULL))
        {
            //Failed to initial the library bass.
            return false;
        }
#ifdef Q_OS_WIN64
    }
#endif
    //Clear the channel flags.
    channelFlags=0;
    //When enabling 32-bit floating converting, check the float support.
    if(m_systemConfigure->data("Float", false).toBool())
    {
        //Check float dsp supporting.
        DWORD fdpsCheck=BASS_StreamCreate(initialSampleRate,
                                          2, BASS_SAMPLE_FLOAT, NULL, 0);
        //If support the float dsp,
        if(fdpsCheck)
        {
            //Free the check channel, recover the memory.
            BASS_StreamFree(fdpsCheck);
            //Set fdps support flag.
            channelFlags |= BASS_SAMPLE_FLOAT;
        }
    }
    //Load complete.
    return true;
}
Ejemplo n.º 29
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    Finished_Init = false;
    AllowInit = false;
    PreBuf_timer = new QTimer;
    Update_timer= new QTimer;
    Ping_timer= new QTimer;
    Spectrum_timer = new QTimer;
    BufferStatusUpdate_timer= new QTimer;
    singleClickTimer=new QTimer;
    m_msgbox = NULL;
    isPlaying=false;
    syncLost=false;
    currentRadio=NULL;
    currentTrack="";
    dConnectionProgress=NULL;
    dDelConfirm=NULL;
    dShowHistory=NULL;
    netManager=NULL;
    currentRadioURL=-1;
    streamsErrLoop=false;
    pSpec=NULL;
    mMoving=false;
    savedVolume=0.5;
    isMuted=false;
    treeSelectionChanged=false;
    isRecording=false;
    newVersionAnimation=NULL;
    recButtonAnimation=NULL;
    isRootOperation=false;
#ifdef VISUALS
    isVisResized=false;
    isVisRendering=false;
    visWin=new VisWinCL(this);
    bigVis=false;
    bigVisRunning=false;
#endif

    initBitRate();
    initOggQualityMap();

    qDebug()<<"Cheking BASS version";
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
        qDebug()<<"An incorrect version of BASS.DLL was loaded";
        QMessageBox::warning(this,QString("warning"),QString("An incorrect version of BASS.DLL was loaded"));
    }

    BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, (void*) _T(PLAYER_HTTPAGENT));


#ifdef Q_OS_WIN
    if (BASS_PluginLoad("bass_aac.dll",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#elif Q_OS_LINUX
    if (BASS_PluginLoad("bass_aac.so",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#endif


    QSettings tSettings(AppPath+CONFIG_FILENAME,QSettings::IniFormat);
    tSettings.setIniCodec("ISO 8859-1");
    Proxy=tSettings.value("proxy","").toString();
    ProxyPort=tSettings.value("proxyport","").toString();
    ProxyUser=tSettings.value("proxyuser","").toString();
    ProxyPass=tSettings.value("proxypass","").toString();
    visualPlugin=tSettings.value("visual",VIS_WIN_PLUG).toString();
    qDebug()<<"visualPlugin="<<visualPlugin;
    recPath=tSettings.value("recpath","").toString();
    recPath=recPath.replace("\\","\\\\");
#ifdef Q_OS_WIN
    if (recPath!="" && recPath.at(recPath.length()-1)!='\\')
        recPath=recPath+"\\";
#else
    if (recPath!="" && recPath.at(recPath.length()-1)!='/')
        recPath=recPath+"/";
#endif

    if (recPath=="") {
#ifdef Q_OS_WIN
        recPath=QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).at(0)+"/");
#endif

#ifdef Q_OS_MAC
        recPath=AppPath.fromLatin1(argv[0]);
        recPath+="/";
#endif
    }

    qDebug()<<"Recording path ="<<recPath;

    if (Proxy!="") {
        qDebug()<<"Proxy="<<Proxy;
        QString tBassProxyStr=ProxyUser;
        if (ProxyPass!="")
            tBassProxyStr+=":"+ProxyPass;
        if (ProxyUser!="")
            tBassProxyStr+="@";
        tBassProxyStr+=Proxy+":"+ProxyPort;
        qDebug()<<"BASSProxy="<<tBassProxyStr;
        qDebug()<<"BASSProxy="<<tBassProxyStr.toLatin1().data();
        //strcpy(proxyStrChar,Proxy.toLatin1().data());
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,tBassProxyStr.toLatin1().data());
        //BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,&proxyStrChar);
    }
    else {
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, NULL);
    }

    //if( !InitVersion() ) ErrorMsgBox(_T("\n Error Setting up Version strings \n"));
    if( !InitBassErrorMap() ) ErrorMsgBox(_T("\n Error setting up Error Msgs \n"));
    if (!BASS_Init(-1,44100,0,NULL,NULL)) {
        ErrorMsgBox(_T("\nUnable to initialize BASS library\n"), 86, false);
        exit(86);
    }

    savedVolume=BASS_GetVolume();
    slVolume->setValue(savedVolume*slVolume->maximum());


#ifdef Q_OS_WIN
    // allocate ACM format buffer, using suggested buffer size
    acmformlen = BASS_Encode_GetACMFormat(0,NULL,0,NULL,0);
    acmform = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmform,0,acmformlen);
    acmduncil = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmduncil, 0, acmformlen);
    //
#endif

    connect(radioTree,SIGNAL(AddStationSig(QModelIndex,RadioCL*)),this,SLOT(AddStation(QModelIndex,RadioCL*)));
    connect(radioTree, SIGNAL(treeSelectionChanged(const QModelIndex &, const QModelIndex &)), this,
            SLOT(radioTreeSelectionChanges(const QModelIndex &, const QModelIndex &)));

    qDebug()<<"Connecting timers signals ";
    connect(PreBuf_timer, SIGNAL(timeout()), this, SLOT(prebufTimeout()));
    connect(Update_timer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
    connect(Ping_timer, SIGNAL(timeout()),this, SLOT(pingRadio()));
    connect(Spectrum_timer, SIGNAL(timeout()), this, SLOT(specTimeout()));
    connect(BufferStatusUpdate_timer, SIGNAL(timeout()),this, SLOT(updateBufferStatus()));
    connect(singleClickTimer, SIGNAL(timeout()),this, SLOT(singleClickTimeout()));

    qDebug()<<"Connecting mgh signals";
    connect( &mgh, SIGNAL(SendUpdTrackInfo(QString)), this, SLOT(on_UpdTrackInfo(QString)) );
    connect( &mgh, SIGNAL(SendUpdRadioInfo(QString,QString,QString,QString)), this, SLOT(on_UpdRadioInfo(QString,QString,QString,QString)));
    connect( &mgh, SIGNAL(SendSyncLost()), this, SLOT(on_SyncLost()) );
    connect( &mgh, SIGNAL(SendPlaybackStarts()), this, SLOT(on_PlaybackStarts()) );
    connect( &mgh, SIGNAL(SendClickRecord()), this, SLOT(on_ClickRecord()) );

    qDebug()<<"Creating actions";
    createActions();
    qDebug()<<"Creating tray icon";
    createTrayIcon();

    qDebug()<<"Setting tray icon";
    setIcon(PLAYER_STATUS_INACTIVE);
    trayIcon->setVisible(true);
    trayIcon->show();
    setWindowTitle(QString(PLAYER_NAME)+" v"+RADIOLA_VERSION);

    qDebug()<<"Initializing spectrum image";
    specbuf = NULL;
    specmode = DEFAULT_SPEC_MODE; // spectrum mode
    specpos = 0; // spectrum mode (and marker pos for 2nd mode)
    pSpec = new QImage(SPECWIDTH, SPECHEIGHT, QImage::Format_Indexed8);
    // setup palette
    pSpec->setColor(0, qRgb(0,0,0));
    for(int a=1; a < 128; a++) {
        pSpec->setColor(a, qRgb(2*a, 256-2*a, 0));
    }
    for(int a=0; a < 32; a++) {
        pSpec->setColor(128+a, qRgb(0, 0, 8*a));
        pSpec->setColor(128+32+a, qRgb(8*a, 0, 255));
        pSpec->setColor(128+64+a, qRgb(255, 8*a, 8*(31-a)));
        //pSpec->setColor(128+64+a, qRgb(8*(31-a), 8*a, 8*a));
        pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
        //pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
    }
    pSpec->setColor(254, qRgb(112, 112, 255));
    pSpec->setColor(253, qRgb(255, 128, 128));
    pSpec->setColor(255, qRgb(212,208,200));    // background color
    // create the bitmap
    specbuf = (BYTE*)pSpec->bits();
    pSpec->fill(255);
    specButton->setSpec(pSpec);

    readSettings();

    qDebug()<<"Connecting tray signals ";
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    setupRadioTree();

    historyFile.setFileName(GetHistoryDir());

    if (!historyFile.open(QIODevice::ReadWrite | QIODevice::Append)) {
        qDebug()<<"Unable to open history file for write"<<historyFile.fileName();
        return;
    }

    StopPlayback();

    QIcon icon = QIcon(MAINWIN_ICON);
    setWindowIcon(icon);

    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(showSettings()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(showRecPath()));
    new QShortcut(QKeySequence(Qt::Key_F1), this, SLOT(showHelp()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(showHistory()));
#ifdef Q_OS_WIN
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this, SLOT(showVisualization()));
#endif
    new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_MediaPlay), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(removeRow()));
    new QShortcut(QKeySequence(Qt::Key_Insert), this, SLOT(insertStation()));
    new QShortcut(QKeySequence(Qt::Key_Plus), this, SLOT(insertSubfolder()));

    QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
    effect->setBlurRadius(1); //Adjust accordingly
    effect->setOffset(3,3); //Adjust accordingly
    setShadow(bnShowHistory);
    setShadow(pbPlay);
    setShadow(pbRecord);
    setShadow(pbQuit);

    recButtonAnimation=new QMovie(":/images/rec_animation.gif");
    connect(recButtonAnimation,SIGNAL(frameChanged(int)),this,SLOT(setRecButtonIcon(int)));

    singleClickTimer->setInterval(QApplication::doubleClickInterval());
    singleClickTimer->setSingleShot(true);

    CheckNewVersion();

    netManager = new QNetworkAccessManager(this);
    if (Proxy!="") {
        netManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,Proxy,ProxyPort.toInt(),ProxyUser,ProxyPass));
    }
    connect(netManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(pingReply(QNetworkReply*)));
}
Ejemplo n.º 30
0
int main(int argc, char* argv[])
{
	regex_t fregex;

	gtk_init(&argc,&argv);

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize default device
	if (!BASS_Init(-1,44100,0,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	// initialize GUI
	glade=glade_xml_new(GLADE_PATH"speakers.glade",NULL,NULL);
	if (!glade) return 0;
	win=GetWidget("window1");
	if (!win) return 0;
	glade_xml_signal_autoconnect(glade);

	{ // check how many speakers the device supports
		BASS_INFO i;
		BASS_GetInfo(&i);
		if (i.speakers<8) {
			gtk_widget_set_sensitive(GetWidget("open4"),FALSE);
			gtk_widget_set_sensitive(GetWidget("swap3"),FALSE);
		}
		if (i.speakers<6) {
			gtk_widget_set_sensitive(GetWidget("open3"),FALSE);
			gtk_widget_set_sensitive(GetWidget("swap2"),FALSE);
		}
		if (i.speakers<4) {
			gtk_widget_set_sensitive(GetWidget("open2"),FALSE);
			gtk_widget_set_sensitive(GetWidget("swap1"),FALSE);
		}
	}

	{ // initialize file selector
		GtkFileFilter *filter;
		filesel=gtk_file_chooser_dialog_new("Open File",GTK_WINDOW(win),GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"Playable files");
		regcomp(&fregex,"\\.(mo3|xm|mod|s3m|it|umx|mp[1-3]|ogg|wav|aif)$",REG_ICASE|REG_NOSUB|REG_EXTENDED);
		gtk_file_filter_add_custom(filter,GTK_FILE_FILTER_FILENAME,FileExtensionFilter,&fregex,NULL);
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"All files");
		gtk_file_filter_add_pattern(filter,"*");
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
	}

	gtk_widget_show(win);
	gtk_main();

	gtk_widget_destroy(filesel);
	regfree(&fregex);

	BASS_Free();

    return 0;
}