Exemplo n.º 1
0
void AudioClip::play()
{
	if (loop)
		BASS_ChannelFlags(hm, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);
	else
        BASS_ChannelFlags(hm, 0, BASS_SAMPLE_LOOP);

	if (play_once)
	{
		if (oshot)
		{
			BASS_ChannelSetAttribute(hm, BASS_ATTRIB_PAN, pan);
			BASS_ChannelSetAttribute(hm, BASS_ATTRIB_VOL, volume);
			BASS_ChannelSetAttribute(hm, BASS_ATTRIB_TEMPO_PITCH, pitch);
			BASS_ChannelPlay(hm, TRUE);
			playing = true;
			oshot = false;
		}
	}
	else
	{
		BASS_ChannelSetAttribute(hm, BASS_ATTRIB_PAN, pan);
		BASS_ChannelSetAttribute(hm, BASS_ATTRIB_VOL, volume);
		BASS_ChannelSetAttribute(hm, BASS_ATTRIB_TEMPO_PITCH, pitch);
		BASS_ChannelPlay(hm, TRUE);
		playing = true;
	}
}
Exemplo n.º 2
0
bool CClientSound::Play3D ( const SString& strPath, const CVector& vecPosition, bool bLoop )
{
    long lFlags = BASS_STREAM_AUTOFREE | BASS_SAMPLE_3D | BASS_SAMPLE_MONO;
    if ( bLoop )
        lFlags |= BASS_SAMPLE_LOOP;

    // Try to load the sound file
    if (
        ( m_pSound = BASS_StreamCreateFile ( false, strPath, 0, 0, lFlags ) )
     || ( m_pSound = BASS_MusicLoad ( false, strPath, 0, 0, lFlags, 0) )
        )
    {
        m_b3D = true;
        m_strPath = strPath;
        m_vecPosition = vecPosition;
        BASS_3DVECTOR pos ( vecPosition.fX, vecPosition.fY, vecPosition.fZ );
        BASS_ChannelSet3DPosition ( m_pSound, &pos, NULL, NULL );
        BASS_ChannelSet3DAttributes ( m_pSound, BASS_3DMODE_NORMAL, 1.0f, 0.5f, 360, 360, 1.0f );
        BASS_ChannelPlay ( m_pSound, false );
        BASS_ChannelGetAttribute ( m_pSound, BASS_ATTRIB_FREQ, &m_fDefaultFrequency );
        return true;
    }
    g_pCore->GetConsole()->Printf ( "BASS ERROR %d in Play3D  path = %s", BASS_ErrorGetCode(), strPath.c_str() );
    return false;
}
Exemplo n.º 3
0
void CClientSound::ThreadCallback ( HSTREAM pSound )
{
    if ( pSound )
    {
        m_pSound = pSound;
        if ( m_b3D )
        {
            BASS_3DVECTOR pos ( m_vecPosition.fX, m_vecPosition.fY, m_vecPosition.fZ );
            BASS_ChannelSet3DPosition ( pSound, &pos, NULL, NULL );
            BASS_ChannelSet3DAttributes ( pSound, BASS_3DMODE_NORMAL, 1.0f, 0.5f, 360, 360, 1.0f );
        }
        // Set a Callback function for download finished
        BASS_ChannelSetSync ( pSound, BASS_SYNC_DOWNLOAD, 0, &DownloadSync, this );
        BASS_ChannelGetAttribute ( pSound, BASS_ATTRIB_FREQ, &m_fDefaultFrequency );
        BASS_ChannelPlay ( pSound, false );
    }
    else
        g_pCore->GetConsole()->Printf ( "BASS ERROR %d in PlayStream  b3D = %s  path = %s", BASS_ErrorGetCode(), m_b3D ? "true" : "false", m_strPath.c_str() );
    
    // Call onClientSoundStream LUA event
    CLuaArguments Arguments;
    Arguments.PushBoolean ( pSound ? true : false );
    Arguments.PushNumber ( GetLength () );
    this->CallEvent ( "onClientSoundStream", Arguments, true );
}
Exemplo n.º 4
0
bool Player::PrebufTimerProc()
{
        QWORD progress = BASS_StreamGetFilePosition(stream,BASS_FILEPOS_BUFFER)*100/BASS_StreamGetFilePosition(stream,BASS_FILEPOS_END);

        if (progress>75 || !BASS_StreamGetFilePosition(stream,BASS_FILEPOS_CONNECTED)) { // over 75% full (or end of download)
                { // get the broadcast name and URL
                        const char *icy=BASS_ChannelGetTags(stream,BASS_TAG_ICY);
                        if (!icy) icy=BASS_ChannelGetTags(stream,BASS_TAG_HTTP); // no ICY tags, try HTTP
                        if (icy) {

                        }
                }
                // get the stream title and set sync for subsequent titles
                //DoMeta();
                //BASS_ChannelSetSync(chan,BASS_SYNC_META,0,&MetaSync,0); // Shoutcast
                //BASS_ChannelSetSync(chan,BASS_SYNC_OGG_CHANGE,0,&MetaSync,0); // Icecast/OGG
                // set sync for end of stream
                //BASS_ChannelSetSync(chan,BASS_SYNC_END,0,&EndSync,0);
                // play it!
                BASS_ChannelPlay(stream,FALSE);

                return FALSE; // stop monitoring
        } else {
                return TRUE; // continue monitoring
        }
}
Exemplo n.º 5
0
		// play
		void BassSound3D::Play()
		{
			m_channel = BASS_SampleGetChannel(m_handle, FALSE);

			if (m_looping)
			{
				BASS_ChannelFlags(m_channel, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);
			}
			else
			{
				BASS_ChannelFlags(m_channel, 0, BASS_SAMPLE_LOOP);
			}

			BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, m_volume);

			BASS_ChannelSet3DAttributes(m_channel, -1, m_minDistance, m_maxDistance, -1, -1, -1);

			BASS_3DVECTOR pos(m_Position.x, m_Position.y, m_Position.z);
			BASS_3DVECTOR vel(m_velocity.x, m_velocity.y, m_velocity.z);
			BASS_ChannelSet3DPosition(m_channel, &pos, NULL, &vel);

			BASS_Apply3D();

			BASS_ChannelPlay(m_channel, FALSE);
		}
Exemplo n.º 6
0
/// <summary>
/// Reproduce un sonido a efecto de realizar pruebas (LShift + H).
/// </summary>
void CSoundManager::TestSound ()
{
	DWORD TestSoundId = BASS_SampleLoad(false, "Data/Sounds/Sample/Muerte/swordSwing.wav", 0, 0, 1, BASS_SAMPLE_MONO);

	// Inicializa el canal 
	BASS_SampleGetChannel(TestSoundId, FALSE);
	// Añade la configuración del canal 
	m_bIsOk = BASS_ChannelSetAttribute(TestSoundId, BASS_ATTRIB_VOL, 100)?true:false;

	// Asigna propiedad de loop
	//BASS_ChannelFlags(TestSoundId, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag

	// Generador de float aleatorio dentro del siguiente rango [-60....0....+60]  
	//float randomSemitoneValue = (rand() % ((-60) - 60 + 1)) + (-60);


	// TO DO: No funciona
	//bool worked = BASS_ChannelSetAttribute(TestSoundId,BASS_ATTRIB_TEMPO_PITCH,randomSemitoneValue)?true:false;

	//if (worked == false)
	//{
	//	int errorCode = BASS_ErrorGetCode();
	//	errorCode = 0;
	//}


	// Reproducción del canal 
	BASS_ChannelPlay(TestSoundId, FALSE);
}
Exemplo n.º 7
0
Plane::Plane(std::string meshdir, std::string texturedir, Vector3 position)
: MovingObject(meshdir, texturedir, position, false){
	this->speed        = 0;
	this->acceleration = 50;
	this->deceleration = 5;
	this->max_speed	   = 200;
	this->min_speed	   = 50;
	this->std_speed    = 5;
	this->roll         = 3;
	this->v_roll       = 2;
	this->h_roll       = 1;
	this->friction     = 0.01;

	numBullets   = 10000;
	bulletsShoot = 0;

	cadencia = 0.25;

	name_ = "Plane " + id;

	motor = BASS_SampleLoad(false,"..\\..\\data\\sound\\motor.mp3",0,0,3,BASS_SAMPLE_LOOP);
	motorSampleChannel = BASS_SampleGetChannel(motor,false);
	BASS_ChannelPlay(motorSampleChannel,true);
	BASS_ChannelSetAttribute(motorSampleChannel,BASS_ATTRIB_VOL,0.5);
	BASS_ChannelSet3DAttributes(motorSampleChannel,BASS_3DMODE_NORMAL,1,500,360,360,0.1);

	bullet = BASS_SampleLoad(false,"..\\..\\data\\sound\\shot.mp3",0,0,3,0);
	bulletSampleChannel = BASS_SampleGetChannel(bullet,false);
	BASS_ChannelSetAttribute(bulletSampleChannel,BASS_ATTRIB_VOL,0.7);
	BASS_ChannelSet3DAttributes(bulletSampleChannel,BASS_3DMODE_NORMAL,0,500,360,360,0.1);
}
Exemplo n.º 8
0
void BassPlayer::playPreproccessing() {
    emit statusChanged(media_title, LoadedMedia);

    BASS_CHANNELINFO info;
    if (BASS_ChannelGetInfo(chan, &info))
        channelsCount(info.chans);
    else
        channelsCount(2);

    if (eq_in_use) registerEQ();

    #ifdef BASS_USE_TEMPO
        applyTempoToChannel();
        newTempoProcessing(tempo());
    #endif

    setSampleRateQuality();
    newVolumeProcessing(volume());
    newPanProcessing(pan());

    if (BASS_ChannelPlay(chan, true)) { // stalled with big sized video files
        playPostprocessing(is_paused);

        syncHandle = BASS_ChannelSetSync((HSYNC)chan, BASS_SYNC_END, 0, &endTrackSync, this);
        syncDownloadHandle = BASS_ChannelSetSync(chan, BASS_SYNC_DOWNLOAD, 0, &endTrackDownloading, this);

//        BASS_SYNC_STALL
//        mixtime only	Sync when playback of the channel is stalled/resumed.
//        param : not used. data : 0 = stalled, 1 = resumed.
    } else {
        proceedErrorState();
        qCritical() << "IS NOT PLAYED";
    }
}
Exemplo n.º 9
0
void KNMusicBackendBassThread::play()
{
    //Check:
    // 1. The state is already playing.
    // 2. The channel is null.
    if(m_state==Playing || (!m_channel))
    {
        return;
    }
    //Start the position updater.
    m_positionUpdater->start();
    //Check the playing state before.
    if(m_state==Stopped)
    {
        //Reset the position to fit track playing.
        setPosition(0);
        //Set the volume to the last volume, because of the reset, the
        //volume is back to 1.0.
        BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, m_volume);
    }
    //Play the thread.
    BASS_ChannelPlay(m_channel, FALSE);
    //Update the state.
    setPlayingState(Playing);
}
Exemplo n.º 10
0
/*
	Play
*/
VOID Application::play(HSTREAM stream)
{
	BASS_Start();
	BASS_ChannelPlay(stream, TRUE);
	equalizer.SetFX(stream);
	BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, numVolume);
}
Exemplo n.º 11
0
gboolean PrebufTimerProc(gpointer data)
{ // monitor prebuffering progress
	DWORD progress=BASS_StreamGetFilePosition(chan,BASS_FILEPOS_BUFFER)
		*100/BASS_StreamGetFilePosition(chan,BASS_FILEPOS_END); // percentage of buffer filled
	if (progress>75 || !BASS_StreamGetFilePosition(chan,BASS_FILEPOS_CONNECTED)) { // over 75% full (or end of download)
		{ // get the broadcast name and URL
			const char *icy=BASS_ChannelGetTags(chan,BASS_TAG_ICY);
			if (!icy) icy=BASS_ChannelGetTags(chan,BASS_TAG_HTTP); // no ICY tags, try HTTP
			if (icy) {
				for (;*icy;icy+=strlen(icy)+1) {
					if (!strncasecmp(icy,"icy-name:",9))
						gtk_label_set_text_8859(GTK_LABEL(GetWidget("status2")),icy+9);
					if (!strncasecmp(icy,"icy-url:",8))
						gtk_label_set_text_8859(GTK_LABEL(GetWidget("status3")),icy+8);
				}
			} else
				gtk_label_set_text(GTK_LABEL(GetWidget("status2")),"");
		}
		// get the stream title and set sync for subsequent titles
		DoMeta();
		BASS_ChannelSetSync(chan,BASS_SYNC_META,0,&MetaSync,0); // Shoutcast
		BASS_ChannelSetSync(chan,BASS_SYNC_OGG_CHANGE,0,&MetaSync,0); // Icecast/OGG
		// set sync for end of stream
		BASS_ChannelSetSync(chan,BASS_SYNC_END,0,&EndSync,0);
		// play it!
		BASS_ChannelPlay(chan,FALSE);
		return FALSE; // stop monitoring
	} else {
		char text[20];
		sprintf(text,"buffering... %d%%",progress);
		gtk_label_set_text(GTK_LABEL(GetWidget("status2")),text);
		return TRUE; // continue monitoring
	}
}
Exemplo n.º 12
0
HCHANNEL BassSoundEngine::PlayMusic(string filename, CHANNEL Ichannel, bool loop, float volume)
{
	if(Ichannel<0||Ichannel>=maxChannel)
	{
		Ichannel = GetNewChannel();
		if(Ichannel<0)
			return NULL;
	}else
		FreeChannel(Ichannel);

	HSTREAM sound = ReadMusic(filename);

	DWORD hr;

	// start play
	hr = BASS_ChannelPlay(sound, TRUE);

	// set volume
	volumeDes[Ichannel] = volume*defaultVolume;
	hr = BASS_ChannelSetAttribute(sound, BASS_ATTRIB_VOL, volumeDes[Ichannel]);

	// set loop
	if(loop)
		hr = BASS_ChannelFlags(sound, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);

	channel[Ichannel] = sound;

	return sound;
}
Exemplo n.º 13
0
void BassSoundEngine::PlaySound(string filename, float volume)
{
	HSAMPLE sound = ReadSound(filename);
	HSTREAM channel = BASS_SampleGetChannel(sound, FALSE);
	BASS_ChannelSetAttribute(channel, BASS_ATTRIB_VOL, volume*defaultVolume);
	BASS_ChannelPlay(channel, TRUE);
}
Exemplo n.º 14
0
void KNMusicBackendBassThread::restore(const QString &updatedFilePath)
{
    //Check out the saved position, if it's -1, means it never saved before.
    //Ignore the invalid call.
    if(m_savedPosition==-1)
    {
        return;
    }
    //Check out the updated file path.
    QString restoreFilePath=
            updatedFilePath.isEmpty()?m_filePath:updatedFilePath;
    //Reload the bass thread.
    loadBassThread(restoreFilePath);
    //Reset the postion.
    setPosition(m_savedPosition);
    //Set the volume to the last volume, because of the reset, the
    //volume is back to 1.0.
    BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, m_volume);
    //Check out the state.
    if(m_state==Playing)
    {
        //Start the updater.
        m_positionUpdater->start();
        //Play the thread.
        BASS_ChannelPlay(m_channel, FALSE);
    }
    //Reset the saved position.
    m_savedPosition=-1;
}
Exemplo n.º 15
0
BOOL CALLBACK RecordingCallback(HRECORD handle, const void *buffer, DWORD length, void *user)
{
	DWORD bl;
	BASS_StreamPutData(chan,buffer,length); // feed recorded data to output stream
	bl=BASS_ChannelGetData(chan,NULL,BASS_DATA_AVAILABLE); // get output buffer level
	if (prebuf) { // prebuffering
		if (bl>=prebuf+length) { // gone 1 block past the prebuffering target
#ifdef ADJUSTRATE
			targbuf=bl; // target the current level
			prevbuf=0;
#endif
			prebuf=0; // finished prebuffering
			BASS_ChannelPlay(chan,FALSE); // start the output
		}
	} else { // playing
#ifdef ADJUSTRATE
		if (bl<targbuf) { // buffer level is below target, slow down...
			rate--;
			BASS_ChannelSetAttribute(chan,BASS_ATTRIB_FREQ,rate);
			prevbuf=0;
		} else if (bl>targbuf && bl>=prevbuf) { // buffer level is high and not falling, speed up...
			rate++;
			BASS_ChannelSetAttribute(chan,BASS_ATTRIB_FREQ,rate);
			prevbuf=bl;
		}
#endif
	}
	return TRUE; // continue recording
}
Exemplo n.º 16
0
render::render(char* song, bool play) {
	this->play = play;
	running = setupSDL();

	if (play) {
		BASS_Init(-1, 44100, 0, NULL, NULL);
		HSTREAM stream;
		stream = BASS_StreamCreateFile(false, song, 0, 0, BASS_SAMPLE_FLOAT | BASS_STREAM_PRESCAN);
		sound_chan = stream;
		BASS_ChannelPlay(sound_chan, false);
	}


	srand(time(NULL));
	for (int i = 0; i < BALL_SIZE; i++) {
		balls[i].setX(rand()%BOX_SIZE*2);
		balls[i].setY(rand()%BOX_SIZE*2);
		balls[i].setZ(rand()%BOX_SIZE*2);
	}

	rotx = 0;
	roty = 0;
	rotz = 0;
	box_x = 0;
	box_y = 0;
	box_z = 0;
	posx = 0;
	posy = 0;
	posz = 100;
	max = BALL_SIZE;
}
Exemplo n.º 17
0
/*
	WM_COMMAND
*/
VOID DlgPlayList::Cls_OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
{
	switch (id)
	{
		case IDC_PLAYLIST:
		{
			if (codeNotify == LBN_DBLCLK)
			{
				INT idx = SendMessage(hPlayList, LB_GETCURSEL, 0, 0);			//получение индекса выделенного элемента
				Application::_this->hStream = songs[idx].hStream;				//присвоение основному потоку поток выбранного элемента
				Application::_this->secPlaying = 0;								//обнуление секунд
				Application::_this->setRangeTrackBarPlaySong(Application::_this->hStream);		//установка диапазона для полосы прокурутки
				DlgEqualizer::_this->SetFX(Application::_this->hStream);		//установка настроек для каналов регуляции звучания
				BASS_Stop();			//остановка потока
				BASS_ChannelStop(Application::_this->hStream);		//остановка канала
				BASS_Start();			//запуск потока
				BASS_ChannelPlay(Application::_this->hStream, TRUE);	//запуск канала
				SetTimer(GetParent(hDlg), Application::_this->id_timer, 1000, 0);			//запуск таймера для времени проигрывания
				SetTimer(GetParent(hDlg), Application::_this->idTimerBySpectr, 100, 0);		//запуск таймера для спектра
				BASS_ChannelSetAttribute(Application::_this->hStream, BASS_ATTRIB_VOL, Application::_this->numVolume);
			}
			break;
		}
		case IDC_ADDSONG:
		{
			SendMessage(GetParent(hwnd), WM_COMMAND, IDC_ADDSONG, 0);
			break;
		}
		default:
			break;
	}
}
Exemplo n.º 18
0
bool playMOD (int f, int a, int fromTrack) {
	if (soundOK) {

		stopMOD (a);

		setResourceForFatal (f);
		uint32_t length = openFileFromNum (f);
		if (length == 0) return NULL;

		char * memImage;
		memImage = loadEntireFileToMemory (bigDataFile, length);
		if (! memImage) return fatal (ERROR_MUSIC_MEMORY_LOW);

		mod[a] = BASS_MusicLoad (true, memImage, 0, length, BASS_MUSIC_LOOP|BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);
		delete memImage;

		if (! mod[a]) {

		}
		else
		{
			setMusicVolume (a, defVol);

			if (! BASS_ChannelPlay (mod[a], true) )
				debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());

			BASS_ChannelSetPosition (mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER);
			BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP, BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP);
		}
		setResourceForFatal (-1);
	}
    return true;
}
Exemplo n.º 19
0
void BASS_AudioInterface::insertData(float* data,int nSamples)
{
	
	for (int i=0;i<nSamples;i++)
	{
		if (mBuffSize < mMaxBuffSize)
		{
			mTempBuffer[mBuffSize++] = data[i];

		}
		
		if (mBuffSize == mFreq * mNumChannels / 10) {

			DWORD err = BASS_StreamPutData(mStream, mTempBuffer, mBuffSize * 4);
	
			mBuffSize = 0;
			
			DWORD state = BASS_ChannelIsActive(mStream);
	
			if (state != BASS_ACTIVE_PLAYING) {
				BASS_ChannelPlay(mStream, 0);
			}
		
		}
	
	}
		
}
Exemplo n.º 20
0
void OpenClicked(GtkButton *obj, gpointer data)
{
	int resp=gtk_dialog_run(GTK_DIALOG(filesel));
	gtk_widget_hide(filesel);
	if (resp==GTK_RESPONSE_ACCEPT) {
		char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
		// free both MOD and stream, it must be one of them! :)
		BASS_MusicFree(chan);
		BASS_StreamFree(chan);
		if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))
			&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMPS|BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT,1))) {
			// whatever it is, it ain't playable
			gtk_button_set_label(obj,"click here to open a file...");
			Error("Can't play the file");
		} else {
			BASS_CHANNELINFO info;
			BASS_ChannelGetInfo(chan,&info);
			if (info.chans!=2) { // the DSP expects stereo
				gtk_button_set_label(obj,"click here to open a file...");
				BASS_MusicFree(chan);
				BASS_StreamFree(chan);
				Error("only stereo sources are supported");
			} else {
				gtk_button_set_label(obj,file);
				// setup DSPs on new channel and play it
				RotateToggled(GTK_TOGGLE_BUTTON(GetWidget("rotate")),0);
				EchoToggled(GTK_TOGGLE_BUTTON(GetWidget("echo")),0);
				FlangerToggled(GTK_TOGGLE_BUTTON(GetWidget("flanger")),0);
				BASS_ChannelPlay(chan,FALSE);
			}
		}
		g_free(file);
	}
}
Exemplo n.º 21
0
// select a file to play, and play it
BOOL PlayFile()
{
	BOOL ret=FALSE;
	regex_t fregex;
	GtkWidget *filesel; // 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);
	if (gtk_dialog_run(GTK_DIALOG(filesel))==GTK_RESPONSE_ACCEPT) {
		char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
		gtk_widget_hide(filesel);
		if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP))
			&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,1))) {
			Error("Can't play file");
		} else {
			BASS_ChannelPlay(chan,FALSE);
			ret=TRUE;
		}
		g_free(file);
	}
	gtk_widget_destroy(filesel);
	return ret;
}
Exemplo n.º 22
0
void KNMusicBackendBassThread::play()
{
    //Check if the thread data if empty.
    if(m_filePath.isEmpty())
    {
        return;
    }
    //Check the state.
    if(m_playingState!=PlayingState)
    {
        //Start the position updater first.
        m_positionUpdater->start();
        //Check whether is now is playing or not.
        if(m_stoppedState)
        {
            //Reset flag.
            m_stoppedState=false;
            //Reset the position to fit track playing.
            setPosition(0);
            //Set the volume to the last volume, because of the reset, the
            //volume is back to 1.0.
            BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, m_lastVolume);
        }
        //Play the thread.
        BASS_ChannelPlay(m_channel, FALSE);
        //Reset the state.
        setState(PlayingState);
    }
}
Exemplo n.º 23
0
// select a file to play, and play it
BOOL PlayFile()
{
	BOOL ret=FALSE;
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
	if (!NavDialogRun(fileDialog)) {
		NavReplyRecord r;
		if (!NavDialogGetReply(fileDialog,&r)) {
			AEKeyword k;
			FSRef fr;
			if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
				char file[256];
				FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
				if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP))
					&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP,1))) {
					Error("Can't play file");
				} else {
					BASS_ChannelPlay(chan,FALSE);
					ret=TRUE;
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
	return ret;
}
Exemplo n.º 24
0
void InitSoundSystem(HWND hwnd)
{
	if (!BASS_Init(-1,44100,0,hwnd,NULL))
	ExitProcess(0);
	chan=BASS_MusicLoad(FALSE,"mario airlines (keygen edit).xm",0,0,BASS_SAMPLE_LOOP|BASS_MUSIC_RAMPS|BASS_MUSIC_PRESCAN|BASS_MUSIC_SURROUND2,0);
	BASS_ChannelPlay(chan,FALSE);
}
Exemplo n.º 25
0
pascal void PrebufTimerProc(EventLoopTimerRef inTimer, void *inUserData)
{ // monitor prebuffering progress
	DWORD progress=BASS_StreamGetFilePosition(chan,BASS_FILEPOS_BUFFER)
		*100/BASS_StreamGetFilePosition(chan,BASS_FILEPOS_END); // percentage of buffer filled
	if (progress>75 || !BASS_StreamGetFilePosition(chan,BASS_FILEPOS_CONNECTED)) { // over 75% full (or end of download)
		RemoveEventLoopTimer(prebuftimer); // finished prebuffering, stop monitoring
		{ // get the broadcast name and URL
			const char *icy=BASS_ChannelGetTags(chan,BASS_TAG_ICY);
			if (!icy) icy=BASS_ChannelGetTags(chan,BASS_TAG_HTTP); // no ICY tags, try HTTP
			if (icy) {
				for (;*icy;icy+=strlen(icy)+1) {
					if (!strncasecmp(icy,"icy-name:",9))
						SetStaticText(31,icy+9);
					if (!strncasecmp(icy,"icy-url:",8))
						SetStaticText(32,icy+8);
				}
			} else
				SetStaticText(31,"");
		}
		// get the stream title and set sync for subsequent titles
		DoMeta();
		BASS_ChannelSetSync(chan,BASS_SYNC_META,0,&MetaSync,0); // Shoutcast
		BASS_ChannelSetSync(chan,BASS_SYNC_OGG_CHANGE,0,&MetaSync,0); // Icecast/OGG
		// set sync for end of stream
		BASS_ChannelSetSync(chan,BASS_SYNC_END,0,&EndSync,0);
		// play it!
		BASS_ChannelPlay(chan,FALSE);
	} else {
		char text[20];
		sprintf(text,"buffering... %d%%",progress);
		SetStaticText(31,text);
	}
}
Exemplo n.º 26
0
bool CAudio::Play()
{
	// Do we have a valid channel?
	if(m_dwChannel != 0)
		return (BASS_ChannelPlay(m_dwChannel, FALSE) != 0);

	return false;
}
HRESULT CBSoundBuffer::Resume()
{
	if (m_Stream)
	{
		BASS_ChannelPlay(m_Stream, FALSE);
	}
	return S_OK;
}
Exemplo n.º 28
0
bool BassPlayer::resumeProcessing() {
    if (!BASS_ChannelPlay(chan, false)) {
        qDebug() << "Error resuming";
        return false;
    }

    return true;
}
void EkgWidget::beat() {
	_beatt = 1.f;

	if(_beepSample != (DWORD)-1 && _sound) {
		HCHANNEL chan = BASS_SampleGetChannel(_beepSample, false);
		BASS_ChannelPlay(chan, true);
	}
}
Exemplo n.º 30
0
static void bass_pause(void *d, int flag)
{
	HSTREAM h = *((HSTREAM *)d);
	if (flag)
		BASS_ChannelPause(h);
	else
		BASS_ChannelPlay(h, false);
}