本文整理汇总了C++中Music类的典型用法代码示例。如果您正苦于以下问题:C++ Music类的具体用法?C++ Music怎么用?C++ Music使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Music类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
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]);
}
}
示例2: operator
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;
}
}
示例3: operator
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;
}
}
示例4: Resource
/**
* 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());
}
示例5: Mix_PlayMusic
void Mixer_SDL::playMusic(Music& music)
{
if(mActAsNull)
return;
if(!music.loaded())
return;
Mix_PlayMusic(music.music(), -1);
}
示例6: search
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);
}
}
示例7: pauseGame
void HudLayer::pauseGame(IMainGame* game, Music music) {
SDL_Log("Game Paused");
if (game->checkPaused() == false) {
game->setPaused();
music.audioPauseBG();
}
else {
game->setRunning();
music.audioResumeBG();
}
}
示例8: main
/*
* 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;
}
}
示例9: main
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;
}
示例10: findFiles
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);
}
示例11: EvtImage
/**
* É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);
}
示例12: EX
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);
}
示例13: processLevelTick
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);
}
示例14: Mix_FadeInMusic
void Mixer_SDL::fadeInMusic(Music& music, int loops, int delay)
{
if(mActAsNull)
return;
Mix_FadeInMusic(music.music(), loops, delay);
}
示例15: Texture
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;
}