void SystemMusic::v_update(double const timeElapsed) { for (auto const& kv : mapNodes) { auto sp_nodeMusic = kv.second; auto sp_parentEntity = Engine::getInstance()->getEntity(kv.first); if (EntityState::ACTIVE == sp_parentEntity->getState()) { auto sp_componentMusic = getComponent<ComponentMusic>(sp_nodeMusic); LOG_IF(!sp_componentMusic, FATAL) << "Could not retrieve a correct component"; assert(sp_componentMusic); if (sp_componentMusic->isPlaying()) sp_componentMusic->getMusic()->play(); else if (sp_componentMusic->isStopped()) sp_componentMusic->getMusic()->stop(); else if (sp_componentMusic->isPaused()) sp_componentMusic->getMusic()->pause(); } } }
void ALAudio::ME_Play(std::string const &file, int volume, int pitch, int fadein) { SET_CONTEXT(ctx_); alSourcef(me_src_->get(), AL_PITCH, pitch * 0.01f); me_src_->set_volume(volume * 0.01f); me_src_->set_buffer_loader(getMusic(*me_src_, file)); me_src_->fade_in(fadein); }
void ALAudio::ME_Play(std::string const& file, int volume, int pitch) { SET_CONTEXT(ctx_); alSourcef(me_src_->get(), AL_PITCH, pitch * 0.01f); alSourcei(me_src_->get(), AL_LOOPING, AL_FALSE); me_src_->set_volume(volume * 0.01f); me_src_->play_buffer(getMusic(file)); }
void Audio::BGM_Play(std::string const& file, int volume, int pitch) { BGM_Stop(); alSourceRewind(*bgmSource_); alSourcei(*bgmSource_, AL_BUFFER, getMusic(file)); alSourcef(*bgmSource_, AL_GAIN, volume * 0.01f); alSourcei(*bgmSource_, AL_PITCH, pitch * 0.01f); alSourcei(*bgmSource_, AL_LOOPING, AL_TRUE); alSourcePlay(*bgmSource_); }
void Audio::ME_Play(std::string const& file, int volume, int pitch) { eraseStopped(seSource_); boost::shared_ptr<ALuint> src = create_source(); alSourcei(*src, AL_BUFFER, getMusic(file)); alSourcef(*src, AL_GAIN, volume * 0.01f); alSourcei(*src, AL_PITCH, pitch * 0.01f); alSourcei(*src, AL_LOOPING, AL_FALSE); alSourcePlay(*src); meSource_.push_back(src); }
/* * Steps recursively through a directory and collects all music files in a list * curdir: current directory path * files: the list to store filenames in * returns the LAST entry of the list. So the next item is the first in the list */ mptitle *recurse( char *curdir, mptitle *files ) { char dirbuff[2*MAXPATHLEN]; struct dirent **entry; int num, i; if( '/' == curdir[strlen( curdir )-1] ) { curdir[strlen( curdir )-1]=0; } addMessage( 3, "Checking %s", curdir ); /* get all music files */ num = getMusic( curdir, &entry ); if( num < 0 ) { addMessage( 0, "getMusic failed in %s", curdir ); return files; } for( i=0; i<num; i++ ) { activity( "Scanning" ); sprintf( dirbuff, "%s/%s", curdir, entry[i]->d_name ); files=insertTitle( files, dirbuff ); free( entry[i] ); } free( entry ); /* step down subdirectories */ num=getDirs( curdir, &entry ); if( num < 0 ) { addMessage( 0, "getDirs failed on %s", curdir ); return files; } for( i=0; i<num; i++ ) { sprintf( dirbuff, "%s/%s", curdir, entry[i]->d_name ); files=recurse( dirbuff, files ); free( entry[i] ); } free( entry ); return files; }
/** * Plays the specified track if it's not already playing. * @param name Name of the music. * @param random Pick a random track? */ void ResourcePack::playMusic(const std::string &name, bool random) { if (!Options::mute && _playingMusic != name) { int loop = -1; _playingMusic = name; // hacks if (name == "GMGEO1") _playingMusic = "GMGEO"; else if (!Options::musicAlwaysLoop && (name == "GMSTORY" || name == "GMWIN" || name == "GMLOSE")) loop = 0; if (random) { getRandomMusic(name)->play(loop); } else { getMusic(name)->play(loop); } } }
void Sound::playMusic(const char* path) { Mix_PlayMusic(getMusic(path), -1 ); }
void Music::play(const int loops, const double dFadeIn, const double dPos) { Mix_VolumeMusic(MIX_MAX_VOLUME * getStdVolume() * m_fVolume); Mix_FadeInMusicPos(getMusic(), loops, static_cast<int> ( (dFadeIn + getStdFadeIn() ) * 1000) , dPos + getStdPos() ); }
void playMusic() { int a; int i; for (int i = 0; i<devices; i++) { if (is_buzzer[i]) { softToneCreate(pins[i][0]); } else { digitalWrite(pins[i][0], 1); digitalWrite(pins[i][1], HIGH); digitalWrite(pins[i][1], LOW); } } i=-1; while (1) { for (i = 0; i<devices; i++) { if (is_buzzer[i]) { if (millis() >= endTime[i]) { a = note_number[i]; getMusic(i, a); if (song[0] == -2) { return; } softToneWrite (pins[i][0], 0); note_number[i] = note_number[i]+1; softToneWrite (pins[i][0], (freq[(song[1]+3+changes[i])*12 + song[0]])); endTime[i] = millis() + song[2]; } } else { if (millis() >= endTime[i]) { note_number[i] = note_number[i]+1; a = note_number[i]; getMusic(i, a); if (song[0] == -2) { return; } else if (song[0] != -1) { pause_a[i] = (floppyConv /(freq[(song[1]+3+changes[i])*12 + song[0]]))/100; pauseTime[i] = micros() + pause_a[i]; } else { pauseTime[i] = INT_MAX; } endTime[i] = millis() + song[2]; } if (micros() >= pauseTime[i]) { if (dir[i] == 0) dir[i] = 1; else dir[i] = 0; digitalWrite(pins[i][0], dir[i]); pauseTime[i] = micros() + pause_a[i]; digitalWrite(pins[i][1], HIGH); digitalWrite(pins[i][1], LOW); } } } } }
void MusicComposer::addAll(){ music = getMusic(); multiTrack.clear(); multiTrack.push_back(music); }
qint64 Timeline::getLength() const { return (qint64)(getMusic().getLength()*framerate); }
qint64 Timeline::currentFrame() const { return (qint64)(getMusic().getPosition()*framerate); }
/* * Steps recursively through a directory and collects all music files in a list * curdir: current directory path * files: the list to store filenames in */ struct entry_t *recurse( char *curdir, struct entry_t *files ) { struct entry_t *buff=NULL; char dirbuff[MAXPATHLEN]; DIR *directory; FILE *file; struct dirent **entry; int num, i; char *pos; if( _ftverbosity > 2 ) { printf("Checking %s\n", curdir ); } // get all music files according to the blacklist num = getMusic( curdir, &entry ); if( num < 0 ) { fail( "getMusic", curdir, errno ); } for( i=0; i<num; i++ ) { activity("Scanning"); strncpy( dirbuff, curdir, MAXPATHLEN ); if( '/' != dirbuff[strlen(dirbuff)] ) { strncat( dirbuff, "/", MAXPATHLEN ); } strncat( dirbuff, entry[i]->d_name, MAXPATHLEN ); if( isValid(dirbuff) ) { int alen; file=fopen( dirbuff, "r"); if( NULL == file ) fail("Couldn't open file ", dirbuff, errno); if( -1 == fseek( file, 0L, SEEK_END ) ) fail( "fseek() failed on ", dirbuff, errno ); buff=(struct entry_t *)calloc(1, sizeof(struct entry_t)); if(buff == NULL) fail("Out of memory!", "", errno); strncpy( buff->name, entry[i]->d_name, MAXPATHLEN ); alen=genPathName( buff->display, dirbuff, MAXPATHLEN ); // strncpy( buff->title, entry[i]->d_name, MAXPATHLEN ); strncpy( buff->path, curdir, MAXPATHLEN ); strncpy( buff->artist, buff->display, alen ); buff->artist[alen+1]=0; buff->prev=files; buff->next=NULL; if(files != NULL)files->next=buff; buff->size=ftell( file )/1024; files=buff; fclose(file); } free(entry[i]); } free(entry); num=getDirs( curdir, &entry ); if( num < 0 ) { fail( "getDirs", curdir, errno ); } for( i=0; i<num; i++ ) { // activity("Scanning"); sprintf( dirbuff, "%s/%s", curdir, entry[i]->d_name ); files=recurse( dirbuff, files ); free(entry[i]); } free(entry); return files; }