TEST(TestMeiDocument, FlattenedDocTree) { Mei *mei = new Mei(); Music *mus = new Music(); Body *body = new Body(); Staff *staff = new Staff(); Staff *s2 = new Staff(); Note *n1 = new Note(); Note *n2 = new Note(); Note *n3 = new Note(); MeiDocument *doc = new MeiDocument(); mei->addChild(mus); // empty since mei not added as document root yet ASSERT_TRUE(doc->getFlattenedTree().empty()); doc->setRootElement(mei); ASSERT_EQ(2, doc->getFlattenedTree().size()); mus->addChild(body); body->addChild(staff); body->addChild(s2); staff->addChild(n1); staff->addChild(n2); s2->addChild(n3); doc->lookBack(n2, "mei"); ASSERT_EQ(8, doc->getFlattenedTree().size()); staff->removeChild(n2); ASSERT_EQ(7, doc->getFlattenedTree().size()); ASSERT_EQ(s2, doc->getFlattenedTree()[5]); staff->removeChildrenWithName("note"); ASSERT_EQ(6, doc->getFlattenedTree().size()); body->deleteAllChildren(); ASSERT_EQ(3, doc->getFlattenedTree().size()); std::vector<MeiElement*> newChildren; Staff *newStaff1 = new Staff(); Staff *newStaff2 = new Staff(); newChildren.push_back(newStaff1); newChildren.push_back(newStaff2); body->setChildren(newChildren); ASSERT_EQ(5, doc->getFlattenedTree().size()); // check contents MeiElement* elements[] = { mei, mus, body, newStaff1, newStaff2 }; std::vector<MeiElement*> rightOrder (elements, elements + sizeof(elements) / sizeof(MeiElement)); for (int i = 0; i < rightOrder.size(); i++) { // check don't overshoot memory allocation ASSERT_LT(i, doc->getFlattenedTree().size()); ASSERT_EQ(rightOrder[i], doc->getFlattenedTree()[i]); } }
void operator()() { while (_flcPlayer->getFrameCount() >= introSoundTrack[trackPosition].frameNumber) { int command = introSoundTrack[trackPosition].sound; if (command & 0x200) { #ifndef __NO_MUSIC switch(command) { case 0x200: Log(LOG_DEBUG) << "Playing gmintro1"; m = mod->getMusic("GMINTRO1"); m->play(1); break; case 0x201: Log(LOG_DEBUG) << "Playing gmintro2"; m = mod->getMusic("GMINTRO2"); m->play(1); break; case 0x202: Log(LOG_DEBUG) << "Playing gmintro3"; m = mod->getMusic("GMINTRO3"); m->play(1); //Mix_HookMusicFinished(_FlcPlayer::stop); break; } #endif } else if (command & 0x400) { int newSpeed = (command & 0xff); _flcPlayer->setHeaderSpeed(newSpeed); Log(LOG_DEBUG) << "Frame delay now: " << newSpeed; } else if (command <= 0x19) { for (soundInFile **sounds = introSounds; *sounds; ++sounds) // try hybrid sound set, then intro.cat or sample3.cat alone { soundInFile *sf = (*sounds) + command; int channel = trackPosition % 4; // use at most four channels to play sound effects double ratio = (double)Options::soundVolume / MIX_MAX_VOLUME; Log(LOG_DEBUG) << "playing: " << sf->catFile << ":" << sf->sound << " for index " << command; s = mod->getSound(sf->catFile, sf->sound, false); if (s) { s->play(channel); Mix_Volume(channel, sf->volume * ratio); break; } else Log(LOG_DEBUG) << "Couldn't play " << sf->catFile << ":" << sf->sound; } } ++trackPosition; } }
void operator ()() { while (Flc::flc.FrameCount >= introSoundTrack[trackPosition].frameNumber) { int command = introSoundTrack[trackPosition].sound; if (command & 0x200) { #ifndef __NO_MUSIC switch(command) { case 0x200: Log(LOG_DEBUG) << "Playing gmintro1"; m = rp->getMusic("GMINTRO1"); m->play(1); break; case 0x201: Log(LOG_DEBUG) << "Playing gmintro2"; m = rp->getMusic("GMINTRO2"); m->play(1); break; case 0x202: Log(LOG_DEBUG) << "Playing gmintro3"; m = rp->getMusic("GMINTRO3"); m->play(1); Mix_HookMusicFinished(musicDone); break; } #endif } else if (command & 0x400) { Flc::flc.HeaderSpeed = (1000.0/70.0) * (command & 0xff); Log(LOG_DEBUG) << "Frame delay now: " << Flc::flc.HeaderSpeed; } else if (command <= 0x19) { for (soundInFile **sounds = introSounds; *sounds; ++sounds) // try hybrid sound set, then intro.cat or sample3.cat alone { soundInFile *sf = (*sounds) + command; int channel = trackPosition % 4; // use at most four channels to play sound effects Log(LOG_DEBUG) << "playing: " << sf->catFile << ":" << sf->sound << " for index " << command; s = rp->getSound(sf->catFile, sf->sound); if (s) { s->play(channel); Mix_Volume(channel, sf->volume); break; } else Log(LOG_DEBUG) << "Couldn't play " << sf->catFile << ":" << sf->sound; } } ++trackPosition; } }
/** * Copy c'tor. */ Music::Music(const Music& _m): Resource(_m.name()) { MusicReferenceMap::iterator it = Music::_RefMap.find(name()); if(it != Music::_RefMap.end()) { it->second.ref_count++; } loaded(_m.loaded()); }
void Mixer_SDL::playMusic(Music& music) { if(mActAsNull) return; if(!music.loaded()) return; Mix_PlayMusic(music.music(), -1); }
void PlaylistWidget::search(QString s) { for(int i = 0 ; i < m_playlist->musicList().count() ; i ++) { Music *m = m_playlist->musicList().at(i); if(m->title().contains(s, Qt::CaseInsensitive) || m->artist()->name().contains(s, Qt::CaseInsensitive) || m->album()->name().contains(s, Qt::CaseInsensitive)) m_tableWidget->showRow(i); else m_tableWidget->hideRow(i); } }
void HudLayer::pauseGame(IMainGame* game, Music music) { SDL_Log("Game Paused"); if (game->checkPaused() == false) { game->setPaused(); music.audioPauseBG(); } else { game->setRunning(); music.audioResumeBG(); } }
/* * HTTP GET method testing by cURLpp and regex testing by boost. */ int main(int argc, char** argv) { RadioInfo i; if (i.success()) { Music* m = i.music(); std::cout << m->artist() + " — " + m->title() + "\n"; return 0; } else { std::cout << i.error(); return 1; } }
int main() { // Create the main window RenderWindow App(VideoMode(800, 600), "Ejemplo de sfml"); // Load a sprite to display Image Image; if (!Image.LoadFromFile("cute_image.jpg")) return EXIT_FAILURE; Sprite Sprite(Image); // Create a graphical string to display Font Arial; if (!Arial.LoadFromFile("/usr/share/fonts/truetype/LiberationMono-Italic.ttf")){ return EXIT_FAILURE; } String Text("Hello SFML", Arial, 50); // Load a music to play Music Music; if (!Music.OpenFromFile("nice_music.ogg")) { return EXIT_FAILURE; } // Play the music Music.Play(); // Start the game loop // Bucle principal del juego bool Running = true; while (Running) { while (App.IsOpened()) { // Process events Event Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == Event::Closed){ Running = false; App.Close(); } // Escape key pressed if ((Event.Type == Event::KeyPressed) && (Event.Key.Code == Key::Escape)){ Running = false; App.Close(); } } // Clear screen App.Clear(); // Draw the sprite App.Draw(Sprite); // Draw the string App.Draw(Text); // Update the window App.Display(); } } return EXIT_SUCCESS; }
void findFiles(char* argv, list <Music> &newMusic) { WIN32_FIND_DATA FindingFileData = { 0 }; HANDLE hFind = INVALID_HANDLE_VALUE; Music *mySongs = NULL; size_t number = 0; //find the first file hFind = FindFirstFile(argv, &FindingFileData); //check to see if there was an error when finding the first file if (hFind == INVALID_HANDLE_VALUE) { printf("Error\n"); } else { do { //what ever that return true it will equal false This test the directory if (!(FindingFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { mySongs = new Music(FindingFileData.cFileName); if (mySongs == NULL) { printf("Allocation failed \n"); break; } //check to see if it return nothing if ((mySongs->GetArtist() != "") || (mySongs->GetTitle() != "")) { //if it did not push it newMusic.push_back(*mySongs); delete mySongs; } } } while (FindNextFile(hFind, &FindingFileData)); } //get the container number = newMusic.size(); //if the container it not zero allow it sort if (number != MIN_CONTAINER_SIZES) { newMusic.sort(); } //close hFind FindClose(hFind); }
/** * Évènement - Appelé lors du changement de la pochette du titre. L'enregistrement dans le fichier se fait automatiquement */ void PlayList::EvtImage(wxCommandEvent &WXUNUSED(event)) { long position = m_liste->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (0 > position) // ==> -1 return; if (MusicManagerSwitcher::getSearch().getMusics().size() <= static_cast<size_t>(position) ) return; Music* music = Factory::createMusic(*MusicManagerSwitcher::getSearch().getMusics().at(position)); music->SetRecordSleeve(&m_pochette->GetImage()); MusicManagerSwitcher::getSearch().updateMusicContent(position, music); }
void Grafkit::MusicFmodLoader::Load(IResourceManager * const & resman, IResource * source) { MusicResRef dest = dynamic_cast<MusicRes*>(source); if (dest.Invalid()) { throw EX(NullPointerException); } Music* music = new MusicFMOD(); IAssetRef asset = this->GetSourceAsset(resman); music->Initialize(asset); dest->AssingnRef(music); }
void HelpScreen::processLevelTick(unsigned int millisElapsed) { Music *music = (Music*) ResourcesManager::getResource("MenuMusic"); ButtonItem *backButton = (ButtonItem*) userInterface->getItem("ZBackButton"); if (backButton->isPressed()) { music->stop(500); userInterface->startFadeOut(200); actionAfterFade = 1; } if (actionAfterFade > 0 && !userInterface->isFading()) { GameMenu *menu = new GameMenu(); GameApp::getInstance()->setCurrentLevel(menu); } Level::processLevelTick(millisElapsed); }
void Mixer_SDL::fadeInMusic(Music& music, int loops, int delay) { if(mActAsNull) return; Mix_FadeInMusic(music.music(), loops, delay); }
bool Scene::load( string path ) { bool success = false; if ( path.find("/texture/") != -1 ) { Texture * temp = new Texture( path ); if ( temp != NULL && temp->load( renderer ) ) { textures.push_back( temp ); success = true; } } else if ( path.find("/music/") != -1 ) { Music * temp = new Music( path ); if ( temp != NULL && temp->load() ) { music.push_back( temp ); success = true; } } else if ( path.find("/sound/") != -1 ) { Sound * temp = new Sound( path ); if ( temp != NULL && temp->load()) { sounds.push_back( temp ); success = true; } } else if ( path.find("/font/") != -1 ) { Text * temp = new Text( path ); if ( temp != NULL && temp->load()) { textures.push_back( temp ); success = true; } } cout << "Loading :: " << ((success) ? "success" : "failed ") << path << " . " << endl; return success; }
int main(int argc, char** argv) { char buffer[256]; const char music_file_name[] = "music_score.dat"; // const char pitch_data_file_name[] = "pitch_data.dat"; const char pitch_samples_file_name[] = "pitch_samples_freq_(a3-c4-d4#-f4#)"; std::vector<double> pitchSamples; DataReader music_reader(music_file_name); DataReader pitch_sample_reader(pitch_samples_file_name); music_reader.read(buffer); cout<<endl; pitch_sample_reader.read(buffer); cout<<endl; // cin.get(); // //check to see that the file was opened correctly: std::ifstream ifile(pitch_samples_file_name, std::ios::in); if (!ifile.is_open()) { std::cerr << "There was a problem opening the input file!\n"; exit(1);//exit or do additional error checking } double num = 0.0; //keep storing values from the text file so long as data exists: while (ifile >> num) { pitchSamples.push_back(num); } //verify that the scores were stored correctly: #if 0 PitchWindow pw; pitch_idx_t idx = -1; PitchDictionary pd; for (unsigned int i = 0; i < pitchSamples.size(); ++i) { std::cout << pitchSamples[i] << std::endl; idx = testPitchNode(pitchSamples[i]); cout<<"detected pitch: "<<pd.indexToPitchName(pw.insert(idx))<<endl; } #endif MusicDetector md; md.initiaize(); md.registerMusicNoteListener(musicListener); md.startDetection(5); for (unsigned int i = 0; i < pitchSamples.size(); ++i) { md.insert(pitchSamples[i]); } md.stopDetection(); gMusic.display(); return 0; }
/* * * void Play(float fadeout, float fadein, Music &oldmusic){ * if (!m) return; * FSOUND_Stream_SetEndCallback(m,endcallback,0); * FSOUND_Stream_SetSynchCallback(m, endcallback, 0); * channel = FSOUND_Stream_PlayEx(FSOUND_FREE, m, NULL, 1); * FSOUND_SetPaused(channel, 0); * SetVolume(0); * if (fadeout*100>1) { * for (unsigned int i=0;i<fadeout*100;i++) { * SetVolume(i/(float)fadeout); * oldmusic.SetVolume(((float)fadeout-i)/fadeout); * micro_sleep (10000); * } * } * SetVolume(1); * oldmusic.Stop(); * } * void SetVolume(float vol) { * if (m) { * F_API FSOUND_SetVolume(this->channel,(int)(vol*GetMaxVolume())); * } * } */ void Play( float fadeout, float fadein, Music &oldmusic ) { if (!m) return; FSOUND_Stream_SetEndCallback( m, endcallback, 0 ); FSOUND_Stream_SetSynchCallback( m, endcallback, 0 ); channel = FSOUND_Stream_Play( FSOUND_FREE, m ); SetVolume( 0 ); if (fadeout*10 > 1) for (unsigned int i = 0; i < fadeout*10; i++) { float ratio = ( (float) i )/(fadeout*10.); SetVolume( ratio ); oldmusic.SetVolume( 1-ratio ); micro_sleep( 10000 ); } oldmusic.Stop(); oldmusic.Free(); SetVolume( 1 ); }
void ForkedProcess (const char * file, float fade, int fd) { printf ("initing device drivers\n"); if (!FSOUND_Init(44100, 64, FSOUND_INIT_GLOBALFOCUS)) { printf("SOUND Error %d\n", FSOUND_GetError()); exit(1); } Music mus; mus.Load(file); if (mus.m) { mus.Play(fade); printf ("f0rked playing %s\n",file); while (!INET_BytesToRead(fd)) { if (AllDone) { printf ("song done\n"); mus.Free(); return; } } mus.Stop(); mus.Free(); } return; }
// after adding a root to a document, you can find an element TEST(TestMeiDocument, ElementById) { Mei *mei = new Mei(); Music *mus = new Music(); Body *body = new Body(); Staff *staff = new Staff(); Staff *s2 = new Staff(); Note *n1 = new Note(); string wantedId = n1->getId(); Note *n2 = new Note(); Note *n3 = new Note(); Note *n4 = new Note(); MeiDocument *doc = new MeiDocument(); ASSERT_EQ(NULL, doc->getElementById(wantedId)); mei->addChild(mus); mus->addChild(body); body->addChild(staff); body->addChild(s2); staff->addChild(n1); staff->addChild(n2); staff->addChild(n3); s2->addChild(n4); doc->setRootElement(mei); ASSERT_EQ(n1, doc->getElementById(wantedId)); ASSERT_EQ(NULL, doc->getElementById("some-unknown-id")); // After adding the root element, making a new element works Note *n5 = new Note(); string newid = n5->getId(); s2->addChild(n5); ASSERT_EQ(n5, doc->getElementById(newid)); // removing the element from the document, clear from document map s2->removeChild(n5); ASSERT_EQ(NULL, doc->getElementById(newid)); }
TEST(TestMeiDocument, ElementsByName) { Mei *mei = new Mei(); Music *mus = new Music(); Body *body = new Body(); Staff *staff = new Staff(); Staff *s2 = new Staff(); Note *n1 = new Note(); string wantedId = n1->getId(); Note *n2 = new Note(); Note *n3 = new Note(); Note *n4 = new Note(); mei->addChild(mus); mus->addChild(body); body->addChild(staff); body->addChild(s2); staff->addChild(n1); staff->addChild(n2); staff->addChild(n3); s2->addChild(n4); MeiDocument *doc = new MeiDocument(); doc->setRootElement(mei); std::vector<MeiElement*> notes = doc->getElementsByName("note"); ASSERT_EQ(4, notes.size()); std::vector<MeiElement*> rests = doc->getElementsByName("rest"); ASSERT_EQ(0, rests.size()); // After adding the root element, making a new element works Note *n5 = new Note(); staff->addChild(n5); std::vector<MeiElement*> notes_new = doc->getElementsByName("note"); ASSERT_EQ(5, notes_new.size()); }
TEST(TestMeiDocument, DocumentPointers) { Mei *mei = new Mei(); Music *mus = new Music(); Body *body = new Body(); Staff *staff = new Staff(); // If an element is added as a child and neither element is attached to a document, nothing happens. ASSERT_EQ(NULL, mei->getDocument()); mei->addChild(mus); ASSERT_EQ(NULL, mus->getDocument()); MeiDocument *doc = new MeiDocument(); // add root to document, all elements should have their document pointer updated mus->addChild(body); doc->setRootElement(mei); ASSERT_EQ(doc, mei->getDocument()); ASSERT_EQ(doc, mus->getDocument()); ASSERT_EQ(doc, body->getDocument()); // add another element as a child, child element should be linked to the same document body->addChild(staff); ASSERT_EQ(doc, staff->getDocument()); }
Music PlayMusic( const char *file, Music &oldmusic ) { Music music; music.Load( file ); if (music.m == NULL) { changehome( true, false ); music.Load( file ); changehome( false ); if (music.m == NULL) { changehome( true, true ); music.Load( file ); changehome( false ); if (music.m == NULL) return oldmusic; } } sende = false; music.Play( fadeout, fadein, oldmusic ); sende = true; curmus = file; invalid_string = false; return music; }
void unload_world(){ if(world_loaded){ world_loaded=false; image.unload_images(); rtt_manager.unload_textures(); sound_system.unload_sounds(); music.unload_tracks(); engine_interface.unload_data(); } }
bool Play( float fadeout, float fadein, Music &oldmusic ) { if (m) { int fadesteps = fadeout*100; for (int i = fadesteps; i >= 0; i--) { oldmusic.SetVolume( i/(float) fadesteps ); micro_sleep( 10000 ); } Mix_FadeInMusic( m, 1, fadein ) != -1; micro_sleep( fadein*1000000 ); return true; } else { return false; } }
void musicListener (pitch_idx_t detectedIdx, int pitchCounter, Pitch & pitchNode) { // PitchDictionary pd; if (pitchCounter > 10) { // printf ("Detected Note(%s) %d times.\n", pd.indexToPitchName(detectedIdx), pitchCounter); // printf ("PitchNode Statistics: %.2lf[%.2lf%%], %.2lf[%.2lf%%], %.2lf[%.2lf%%], %.2lf[%.2lf%%]\n", // pitchNode.avgNegativeDeviation, pitchNode.avgNegDeviationPercentage(), // pitchNode.avgPositiveDeviation, pitchNode.avgPosDeviationPercentage(), // pitchNode.maxNegativeDeviation, pitchNode.maxNegDeviationPercentage(), // pitchNode.maxPositiveDeviation, pitchNode.maxPosDeviationPercentage() // ); Pitch * pPitch = new Pitch(pitchNode); gMusic.insertAndMergeANote(pPitch); } }
/** * Évènement - Applique les les modifications des TAGs au fichier sélectionné */ void PlayList::OnAppliquerTAG(wxCommandEvent &WXUNUSED(event)) { int position = m_liste->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (position < 0) return; if (MusicManagerSwitcher::getSearch().getMusics().size() <= static_cast<size_t>(position) ) return; Music* music = Factory::createMusic(*MusicManagerSwitcher::getSearch().getMusics().at(position)); music->SetAlbum(m_BoiteAlbum->GetValue()); music->SetName(m_BoiteNom->GetValue()); music->SetArtists(m_BoiteArtiste->GetValue()); music->SetTitle(m_BoiteTitre->GetValue()); music->SetGenres(m_BoiteGenre->GetValue()); music->SetYear(m_BoiteAnnee->GetValue()); MusicManagerSwitcher::getSearch().updateMusicContent(position, music); }
void menu(RenderWindow & window, Music &musicInMenu) { init_texture textu; bool kek = false; musicInMenu.play(); bool isMenu = 1; int menuNum = 0; while (isMenu) { textu.menu1.setColor(Color::White); textu.menu2.setColor(Color::White); textu.menu3.setColor(Color::White); menuNum = 0; window.clear(Color(129, 181, 221)); if (IntRect(100, 30, 300, 50).contains(Mouse::getPosition(window))) { textu.menu1.setColor(Color::Blue); menuNum = 1; } if (IntRect(100, 90, 300, 50).contains(Mouse::getPosition(window))) { textu.menu3.setColor(Color::Blue); menuNum = 3; } if (IntRect(100, 150, 300, 50).contains(Mouse::getPosition(window))) { textu.menu2.setColor(Color::Blue); menuNum = 2; } window.draw(textu.menuBg); window.draw(textu.menu1); window.draw(textu.menu2); window.draw(textu.menu3); if (kek) { window.draw(textu.training); if (IntRect(1200, 90, 50, 50).contains(Mouse::getPosition(window)) && Mouse::isButtonPressed(Mouse::Left)) { kek = false; } } if (Mouse::isButtonPressed(Mouse::Left)) { if (menuNum == 1) isMenu = false; if (menuNum == 2) { window.close(); isMenu = false; } if (menuNum == 3) { kek = true; } } window.display(); } }
bool load_world(){ engine_interface.load_data_game_options(); if(!engine_interface.load_options()){ return false; } if(!main_window.init()){ return false; } image.load_images(); sound_system.load_sounds(); music.prepare_tracks(); engine_interface.load_data_main(); rtt_manager.create_textures(); engine_interface.console.setup(false); engine_interface.chat.setup(true); if(!engine_interface.load_game_commands()){ return false; } engine_interface.load_servers(); //To be safe, this should be at the very bottom of load_world(). image.set_error_image(); world_loaded=true; return true; }
uintptr_t thread_fn() { assert(csound); tick_total = 0.0f; while (PERF_STATUS == CONTINUE) { if (csoundPerformBuffer(csound)) break; if (tick_adjustment > - ticks_per_period) { MYFLT tick_inc = ticks_per_period + tick_adjustment; music.step( tick_inc, secs_per_tick, csound); tick_adjustment = 0.0; tick_total += tick_inc; } else { tick_adjustment += ticks_per_period; } } ll->printf(2, "INFO: performance thread returning 0\n"); return 0; }
void Manager::StartServer() { //if(!db.Connect(conf.GetDbFile().c_str())) // throw std::runtime_error("Database could not be opened"); #ifndef _REMOTE_MODE Music music; #else BaseMusic music; #endif music.GetList().LoadDir(conf.GetDir()); std::thread mplayer( [&music] { music.PlayList(); } ); if(conf.GetAutostart()) { music.SetStatus(Status::Playing); } CommandControler cmd(music); //FIXME: This should not detach #ifdef _NAMED_PIPE std::thread([&, this](){ while(music.GetStatus() != Status::Exit) ProcessCommand(pipe, cmd); }).detach(); #endif #ifdef _TCP_SOCKET std::thread([&, this](){ while(music.GetStatus() != Status::Exit) ProcessCommand(tcp, cmd); }).detach(); #endif mplayer.join(); }