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); }
void AddClicked(GtkButton *obj, gpointer data) { // add a channel 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)); DWORD newchan; // Load a music or sample from "file" if ((newchan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMP|BASS_SAMPLE_LOOP|BASS_SAMPLE_3D,1)) || (newchan=BASS_SampleLoad(FALSE,file,0,0,1,BASS_SAMPLE_LOOP|BASS_SAMPLE_3D|BASS_SAMPLE_MONO))) { Channel *c; chanc++; chans=(Channel*)realloc((void*)chans,chanc*sizeof(Channel)); c=chans+chanc-1; memset(c,0,sizeof(Channel)); c->channel=newchan; BASS_SampleGetChannel(newchan,FALSE); // initialize sample channel { // add it to the list GtkTreeView *tree=GTK_TREE_VIEW(GetWidget("channels")); GtkListStore *tm=GTK_LIST_STORE(gtk_tree_view_get_model(tree)); GtkTreeIter it; gtk_list_store_append(tm,&it); gtk_list_store_set(tm,&it,0,strrchr(file,'/')+1,-1); } } else Error("Can't load file (note samples must be mono)"); g_free(file); } }
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); }
// 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); }
void EkgWidget::beat() { _beatt = 1.f; if(_beepSample != (DWORD)-1 && _sound) { HCHANNEL chan = BASS_SampleGetChannel(_beepSample, false); BASS_ChannelPlay(chan, true); } }
void LoadedSample::PlaySample () { if ( m_playing ) BASS_Start(); else { m_channel = BASS_SampleGetChannel( m_sample, FALSE ); BOOL ret = BASS_ChannelPlay(m_channel, FALSE); int err =BASS_ErrorGetCode(); int x = 0; } }
void BassSoundEngine::PlayHit(float factor) { float vol = systemIni.sndVolume*(0.5f+factor*0.25f); /* FMOD::Channel *channel; system->playSound(FMOD_CHANNEL_FREE, hitWav, false, &channel); channel->setVolume(min(1.0f,vol)*defaultVolume);*/ //channel->setPaused(false); //ERRCHECK(result); HCHANNEL chan = BASS_SampleGetChannel(hitWav, FALSE); BASS_ChannelSetAttribute(chan, BASS_ATTRIB_VOL, min(1.0f,vol)*defaultVolume); BASS_ChannelPlay(chan, true); }
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; }
bool startSound (int f, bool loopy) { if (soundOK) { int a = cacheSound (f); if (a == -1) return false; soundCache[a].looping = loopy; soundCache[a].vol = defSoundVol; soundCache[a].mostRecentChannel = BASS_SampleGetChannel (soundCache[a].sample, false); if (soundCache[a].mostRecentChannel) { BASS_ChannelPlay(soundCache[a].mostRecentChannel, true); BASS_ChannelSetAttribute(soundCache[a].mostRecentChannel, BASS_ATTRIB_VOL, defSoundVol); if (loopy) { BASS_ChannelFlags(soundCache[a].mostRecentChannel, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag } } } return true; }
void ClientGame::PlaySample(HSAMPLE sample) { HCHANNEL channel = BASS_SampleGetChannel(sample, false); BASS_ChannelPlay(channel, true); }
/// <summary> /// Reproduce sonidos usando el volumen dado. /// </summary> ///<param name="SoundName">Nombre del sonido a reproducir.</param> void CSoundManager::PlaySoundVolume (const std::string &SoundName, float _fVolume) { bool pass = false; std::map<std::string, SSoundData>::iterator iter = m_Resources.find(SoundName); if(iter == m_Resources.end()) { // Guarda mensaje de error en el log std::string msg_error = "CSoundManager::PlaySound->No se encontró el identificador del sonido: "; msg_error.append(SoundName.c_str()); LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); return; } SSoundData sData = iter->second; if (sData.m_type == false) // False si es sample { sData.m_Id = BASS_SampleGetChannel(sData.m_Id, FALSE); //Agregarlo a canal de sample en el vector m_Channels; //Canales 2 - 19 if (m_iSamplerChannels == 19) { // El número de canales de sonidos ha llegado a su máximo // Liberar el canal 2 y asignar este sonido a este canal m_iSamplerChannels = 2; } else { // Asignar esta música al canal que corresponde ++m_iSamplerChannels; } m_Channels[m_iSamplerChannels].m_dwSource = sData.m_Id; m_Channels[m_iSamplerChannels].m_fVolumen = _fVolume; } // True si es música else { // 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; } //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 = _fVolume; } // Añade la configuración del canal pass = BASS_ChannelSetAttribute(sData.m_Id, BASS_ATTRIB_VOL, _fVolume) ? true : false; if (pass == false) { int errorCode = BASS_ErrorGetCode(); errorCode = 0; } // Looping sound if (sData.m_Loop == true) { //BASS_ChannelFlags(sData.m_Id, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag to true } if (sData.m_ThreeDimensional == true) { BASS_3DVECTOR vector; vector.x = sData.m_Position.x; vector.y = sData.m_Position.y; vector.z = sData.m_Position.z; bool result = BASS_ChannelSet3DPosition(sData.m_Id, &vector, NULL, NULL)?true:false; if (result == true) { BASS_Apply3D(); } else { int errorCode = BASS_ErrorGetCode(); errorCode = 0; } } if (pass) { // Reproducción del canal pass = BASS_ChannelPlay(sData.m_Id, FALSE)?true:false; if (pass) { std::string msg_debug = "Sonido reproducido con éxito"; } } }