Example #1
0
void CBassAudio::SetTempoValues ( float fSampleRate, float fTempo, float fPitch, bool bReverse )
{
    if ( fTempo != m_fTempo )
    {
        m_fTempo = fTempo;
    }
    if ( fPitch != m_fPitch )
    {
        m_fPitch = fPitch;
    }
    if ( fSampleRate != m_fSampleRate )
    {
        m_fSampleRate = fSampleRate;
    }
    m_bReversed = bReverse;

    // Update our attributes
    if ( m_pSound )
    {
        // TODO: These are lost when the sound is not streamed in
        BASS_ChannelSetAttribute ( m_pSound, BASS_ATTRIB_TEMPO, m_fTempo );
        BASS_ChannelSetAttribute ( m_pSound, BASS_ATTRIB_TEMPO_PITCH, m_fPitch );
        BASS_ChannelSetAttribute ( m_pSound, BASS_ATTRIB_TEMPO_FREQ, m_fSampleRate );
        BASS_ChannelSetAttribute ( BASS_FX_TempoGetSource ( m_pSound ), BASS_ATTRIB_REVERSE_DIR, (float)(bReverse == false ? BASS_FX_RVS_FORWARD : BASS_FX_RVS_REVERSE) );
    }
}
Example #2
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
}
Example #3
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);
}
Example #4
0
bool cSoundEffect::play(unsigned int index)
{
	if( index < m_vecSamples.size() )
	{
		HCHANNEL hChannel = BASS_SampleGetChannel(m_vecSamples[index], FALSE);

		BASS_ChannelSetAttribute(hChannel, BASS_ATTRIB_VOL, 1.0f);
		BASS_ChannelSetAttribute(hChannel, BASS_ATTRIB_PAN, 0.0f);

		return BASS_ChannelPlay(hChannel, TRUE) == TRUE;
	}

	return false;
}
Example #5
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;
}
Example #6
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);
}
Example #7
0
void CClientSound::Process3D ( CVector vecPosition )
{
    if ( !m_pSound || !m_b3D )
        return;

    // Update our position and velocity if we're attached
    CClientEntity* pAttachedToEntity = GetAttachedTo ();
    if ( pAttachedToEntity )
    {
        DoAttaching ();
        CVector vecVelocity;
        if ( CStaticFunctionDefinitions::GetElementVelocity ( *pAttachedToEntity, vecVelocity ) )
            SetVelocity ( vecVelocity );
    }

    // Volume
    float fDistance = DistanceBetweenPoints3D ( vecPosition, m_vecPosition );
    float fDistDiff = m_fMaxDistance - m_fMinDistance;
    float fVolume = 1.0;

    //Transform e^-x to suit our sound
    if ( fDistance <= m_fMinDistance )
        fVolume = 1.0f;
    else if ( fDistance >= m_fMaxDistance )
        fVolume = 0.0f;
    else
        fVolume = exp ( - ( fDistance - m_fMinDistance ) * ( CUT_OFF / fDistDiff ) );

    BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_VOL, fVolume * m_fVolume );
}
Example #8
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);
		}
/// <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);
}
Example #10
0
pascal OSStatus DirEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	DWORD srcChan=BASS_FX_TempoGetSource(chan);
	float dir;
	BASS_ChannelGetAttribute(srcChan, BASS_ATTRIB_REVERSE_DIR, &dir);

	if(dir<0){
		BASS_ChannelSetAttribute(srcChan, BASS_ATTRIB_REVERSE_DIR, BASS_FX_RVS_FORWARD);
		SetControlText(16, "Playing Direction - Forward");
	}else{
		BASS_ChannelSetAttribute(srcChan, BASS_ATTRIB_REVERSE_DIR, BASS_FX_RVS_REVERSE);
		SetControlText(16,"Playing Direction - Reverse");
	}

	return noErr;
}
/*
	Next song
*/
VOID Application::next()
{
	INT allSongs = playlist.songs.size();		//всего песен
	INT next = 0;						//след играющая песня
	if (allSongs > 0)
	{
		//Поиск текущей играемой песни
		for (INT i = 0; i < allSongs; i++)
		{
			if (hStream == playlist.songs[i].hStream)
			{
				next++;
				break;
			}
			next++;
		}
		//Если при нажатии на NextSong достигнут конец списка, перевести указатель на начало списка
		if (next + 1 > allSongs)
			next = 0;

		stop(hStream);								//остановка потока
		hStream = playlist.songs[next].hStream;		//загрузка следующей песни в поток
		secPlaying = 0;								//сброс проигранных секунд
		setRangeTrackBarPlaySong(hStream);			//установка диапазона TrackBar под играющую песню 
		equalizer.SetFX(hStream);					
		play(hStream);								//воспроизвести поток
		SetTimer(GetParent(hTBPlayingSong), id_timer, 1000, 0);	//Запуск таймера 
		SendMessage(playlist.hPlayList, LB_SETCURSEL, next, 0);	//выделяет текущую песня в плейлисте
		BASS_ChannelSetAttribute(hStream, BASS_ATTRIB_VOL, numVolume);
	}
}
Example #12
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);
}
/*
	Play
*/
VOID Application::play(HSTREAM stream)
{
	BASS_Start();
	BASS_ChannelPlay(stream, TRUE);
	equalizer.SetFX(stream);
	BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, numVolume);
}
Example #14
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);
}
Example #15
0
void KNMusicBackendBassThread::setVolume(const int &volumeSize)
{
    float channelVolume=(float)volumeSize/100;
    BASS_ChannelSetAttribute(m_channel, BASS_ATTRIB_VOL, channelVolume);
    //Backup the volume
    m_lastVolume=channelVolume;
}
Example #16
0
void CBassAudio::SetVolume ( float fVolume )
{
    m_fVolume = fVolume;

    if ( m_pSound && !m_b3D )
        BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_VOL, fVolume );
}
/*
	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;
	}
}
Example #18
0
void CBassAudio::SetPlaybackSpeed ( float fSpeed )
{
    m_fPlaybackSpeed = fSpeed;

    if ( m_pSound )
        BASS_ChannelSetAttribute ( m_pSound, BASS_ATTRIB_FREQ, fSpeed * m_fDefaultFrequency );
}
Example #19
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;
}
/*
	Prev song
*/
VOID Application::prev()
{
	INT allSongs = playlist.songs.size();		//всего песен
	INT prev = 0;							//след играющая песня
	if (allSongs > 0)
	{
		//Поиск текущей играемой песни
		for (INT i = 0; i < allSongs; i++)
		{
			if (hStream == playlist.songs[i].hStream)
			{
				break;
			}
			prev++;
		}
		//Если при нажатии на PrevtSong достигнут начало списка, перевести указатель на конец списка
		if (prev - 1 < 0)
			prev = allSongs - 1;
		else
			prev--;

		stop(hStream);				//остановка потока
		hStream = playlist.songs[prev].hStream;		//загрузка следующей песни в поток
		secPlaying = 0;				//обнуление проигранных секунд
		setRangeTrackBarPlaySong(hStream);		//установка диапазона полосы проигрывания
		equalizer.SetFX(hStream);
		play(hStream);				//воспроизвести поток
		SetTimer(GetParent(hTBPlayingSong), id_timer, 1000, 0);
		SendMessage(playlist.hPlayList, LB_SETCURSEL, prev, 0);	//выделяет текущую песня в плейлисте
		BASS_ChannelSetAttribute(hStream, BASS_ATTRIB_VOL, numVolume);
	}
}
Example #21
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);
    }
}
HRESULT CBSoundBuffer::SetPan(float Pan)
{
	if (m_Stream)
	{
		BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_PAN, Pan);
	}
	return S_OK;
}
Example #23
0
void CBassAudio::Process3D ( const CVector& vecPlayerPosition, const CVector& vecCameraPosition, const CVector& vecLookAt )
{
    assert ( m_b3D && m_pSound );

    float fDistance = DistanceBetweenPoints3D ( vecCameraPosition, m_vecPosition );
    if ( m_bPan )
    {
        // Limit panning when getting close to the min distance
        float fPanSharpness = UnlerpClamped ( m_fMinDistance, fDistance, m_fMinDistance * 2 );
        float fPanLimit = Lerp ( 0.35f, fPanSharpness, 1.0f );

        // Pan
        CVector vecLook = vecLookAt - vecCameraPosition;
        CVector vecSound = m_vecPosition - vecCameraPosition;
        vecLook.fZ = vecSound.fZ = 0.0f;
        vecLook.Normalize ();
        vecSound.Normalize ();

        vecLook.CrossProduct ( &vecSound );
        // The length of the cross product (which is simply fZ in this case)
        // is equal to the sine of the angle between the vectors
        float fPan = Clamp ( -fPanLimit, -vecLook.fZ, fPanLimit );

        BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_PAN, fPan );
    }
    else
    {
        // Revert to middle.
        BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_PAN, 0.0f );
    }

    // Volume
    float fDistDiff = m_fMaxDistance - m_fMinDistance;

    //Transform e^-x to suit our sound
    float fVolume;
    if ( fDistance <= m_fMinDistance )
        fVolume = 1.0f;
    else if ( fDistance >= m_fMaxDistance )
        fVolume = 0.0f;
    else
        fVolume = exp ( - ( fDistance - m_fMinDistance ) * ( CUT_OFF / fDistDiff ) );

    BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_VOL, fVolume * m_fVolume );
}
void Player::setSampleRate(int sampleRate) {
	if(BASS_ChannelSetAttribute(_output, BASS_ATTRIB_FREQ, sampleRate))
    {
        Log::msg("Player::setSampleRate - Sample rate set OK");
    }
    else
    {
        Log::error("Bass Error: setting sample rate", GetBassStrError());
    }
}
/*
	WM_HSCROLL
*/
VOID Application::Cls_OnHScroll(HWND hwnd, HWND hwndCtl, UINT code, INT pos)
{
	/*
		Громкость
	*/
	if (hwndCtl == hTBSoundVolume)											//Adjusting the volume control (Настройка регулятора громкости)
	{
		INT p = SendMessage(hTBSoundVolume, TBM_GETPOS, NULL, NULL);		//Получение позиции
		DOUBLE nPos = p * 0.01;		//новая позиция уровня громкости
		/*
			Собственный регулятор громкости
		*/
		SendMessage(hTBSoundVolume, TBM_SETPOS, TRUE, (LPARAM)p);
		BASS_ChannelSetAttribute(hStream, BASS_ATTRIB_VOL, nPos);
		numVolume = nPos;
		/*
			Привязка к windows регулятору громкости
		*/
		//BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, p * 100);
		//BASS_SetVolume(p / 100.f);
		
	}
	/*
		Время проигрывания
	*/	
	else if (hwndCtl == hTBPlayingSong)										
	{
		INT nPos = 0;														//new position
		nPos = SendMessage(hTBPlayingSong, TBM_GETPOS, 0, 0);				//Get new position
		secPlaying = nPos;													//Seconds playing = current position
		QWORD bytePos = BASS_ChannelSeconds2Bytes(hStream, nPos);			//Translated seconds in bytes 
		BASS_ChannelSetPosition(hStream, bytePos, BASS_POS_BYTE);			//Rewind in bytes
		SendMessage(hTBPlayingSong, TBM_SETPOS, TRUE, (LPARAM)nPos);		//Translated position	
	}
	/*
		Баланс
	*/
	else if (hwndCtl == hSlider_Balance)
	{
		INT p = SendMessage(hSlider_Balance, TBM_GETPOS, NULL, NULL);
		BASS_ChannelSetAttribute(Application::_this->hStream, BASS_ATTRIB_PAN, p / 5);
	}
}
Example #26
0
void setMusicVolume (int a, int v) {
	int ret;
	if (soundOK && mod[a])
	{
		ret = BASS_ChannelSetAttribute (mod[a], BASS_ATTRIB_VOL, (float) v / 255);
		if (! ret) {
			debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode());
		}
	}
}
/// <summary>
/// FadeIn de la música que está por sonar (LShift + S).
/// </summary>
/// <param name="&MusicName">Nueva música a reproducir.</param>
void CSoundManager::FadeIn(const std::string &MusicName, DWORD _ulTime)
{
	try
	{
		bool pass = true;
		std::map<std::string, SSoundData>::iterator iter = m_Resources.find(MusicName);
  
		if(iter == m_Resources.end())
		{
			// Guarda mensaje de error en el log
      std::string msg_error = "CSoundManager::FadeIn->No se encontró el identificador de la música: ";
			msg_error.append(MusicName.c_str());
			LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
			return;
		}

		SSoundData sData = iter->second;
	 
		// En caso de que los dos canales de música ya estén asignados
		if (m_iMusicChannels == 1)
		{
			m_iMusicChannels = 0;
		}
		else
		{
			// Asignar esta música al canal 1
			m_iMusicChannels = m_iMusicChannels + 1;
		}
	 
		//Agregarlo a canal de música en el vector m_Channels; 
		m_Channels[m_iMusicChannels].m_dwSource = sData.m_Id;
		m_Channels[m_iMusicChannels].m_fVolumen = 1;
	   
		if (pass)
		{
			// Reproducción del canal 
			BASS_ChannelSetAttribute(sData.m_Id, BASS_ATTRIB_VOL, 0);
 
			BASS_ChannelSlideAttribute(sData.m_Id, BASS_ATTRIB_VOL, sData.m_Volume, _ulTime);

			pass = BASS_ChannelPlay(sData.m_Id, FALSE)?true:false;
 
			if (pass)
			{
				std::string msg_debug = "Sonido reproducido con éxito";
			}
		}	
	}
	catch(CException e)
  {
		// Guarda mensaje de error en el log
		std::string msg_error = "CSoundManager::FadeIn-> El proceso no se llevó a cabo exitosamente.";
  }
}
Example #28
0
BOOL BassSoundEngine::SetTempo(double factor, int channel_id, bool immediate)
{
	if(immediate){
		BOOL hr = BASS_ChannelSetAttribute(channel[channel_id], BASS_ATTRIB_TEMPO, (factor-1.0)*100.0);
		ERRCHECK(hr);
		return hr;
	}else{
		tempo_factor = factor;
		return TRUE;
	}
}
Example #29
0
void setSoundVolume (int a, int v) {
	if (soundOK) {
		int ch = findInSoundCache (a);
		if (ch != -1) {
			if (BASS_ChannelIsActive (soundCache[ch].mostRecentChannel))
			{
				BASS_ChannelSetAttribute (soundCache[ch].mostRecentChannel, BASS_ATTRIB_VOL, (float) v / 255);
			}
		}
	}
}
HRESULT CBSoundBuffer::SetVolume(int Volume)
{
	if (m_Stream)
	{
		// compute the "weighted" value (volume relatively to TSoundType category's volume)
		float resultingVolumePerCent = ((float)Volume / 100.0f) * m_PrivateVolume;
		BASS_ChannelSetAttribute(m_Stream, BASS_ATTRIB_VOL, resultingVolumePerCent / 100.0f);
		// Game->LOG(0, "BASS_Setvolume occurred, integer=%d, privVolume=%d, resulting float value=%f.\n", Volume, m_PrivateVolume, resultingVolumePerCent / 100.0f);
	}
	return S_OK;
}