ContextWidget::ContextWidget(QWidget *parent) : QWidget(parent) , job(0) , alwaysCollapsed(false) , backdropType(PlayQueueView::BI_Cover) , darkBackground(false) , useFanArt(0!=constFanArtApiKey.latin1()) , albumCoverBackdrop(false) , oldIsAlbumCoverBackdrop(false) , fadeValue(1.0) , isWide(false) , stack(0) , onlineContext(0) , splitter(0) , viewSelector(0) { QHBoxLayout *layout=new QHBoxLayout(this); mainStack=new QStackedWidget(this); standardContext=new QWidget(mainStack); mainStack->addWidget(standardContext); layout->setMargin(0); layout->addWidget(mainStack); animator.setPropertyName("fade"); animator.setTargetObject(this); appLinkColor=QApplication::palette().color(QPalette::Link); artist = new ArtistView(standardContext); album = new AlbumView(standardContext); song = new SongView(standardContext); minWidth=album->picSize().width()*2.5; artist->addEventFilter(this); album->addEventFilter(this); song->addEventFilter(this); connect(artist, SIGNAL(findArtist(QString)), this, SIGNAL(findArtist(QString))); connect(artist, SIGNAL(findAlbum(QString,QString)), this, SIGNAL(findAlbum(QString,QString))); connect(album, SIGNAL(playSong(QString)), this, SIGNAL(playSong(QString))); readConfig(); setZoom(); setWide(true); #ifndef SCALE_CONTEXT_BGND QDesktopWidget *dw=QApplication::desktop(); if (dw) { QSize geo=dw->availableGeometry(this).size()-QSize(32, 64); minBackdropSize=geo; minBackdropSize.setWidth(((int)(minBackdropSize.width()/32))*32); minBackdropSize.setHeight(((int)(minBackdropSize.height()/32))*32); maxBackdropSize=QSize(geo.width()*1.25, geo.height()*1.25); } else { minBackdropSize=QSize(Utils::scaleForDpi(1024*3), Utils::scaleForDpi(768*3); maxBackdropSize=QSize(minBackdropSize.width()*2, minBackdropSize.height()*2); } #endif }
void Player::previous() { //QTextStream out(stderr,QIODevice::WriteOnly); last = m_current; selectedReadMode = mypreference->getSelectedReadMode(); QMediaContent* source = NULL; switch(selectedReadMode) { case ONEFILE: case SEQUENTIAL: { m_current = (*myPlaylist)[++position]; source = playSong(m_current);; break; } case RANDOM: { //int pos = (int)((double)rand() / ((double)RAND_MAX + 1) * myPlaylist->size()) int place = 0; if(m_listposition>=1) { place = m_positions.at(--m_listposition); } else { place = (int)((double)rand() / ((double)RAND_MAX + 1) * myPlaylist->size()); m_positions.insert(0,place); m_listposition = 0; } m_current = (*myPlaylist)[place]; source = playSong(m_current); break; } } if(m_current!=NULL) { setTitle(m_current->getReadableTitle()); } m_mediaPlayer->setMedia(*source); m_mediaPlayer->play(); }
void loop() { loopcounter++; adc_key_in = analogRead(0); // read the value from the sensor key = get_key(adc_key_in); // convert into key press if (key >=0){ if(key == 1) {// UP! ++targetF; targetreached = false; storePersistent(targetF); printTarget(); } else if(key == 2) {// DOWN! --targetF; targetreached = false; storePersistent(targetF); printTarget(); } else if(key == 4) {//SELECT targetreached = false; printTarget(); } } if(loopcounter % 5 == 0) { int value = analogRead(thermometerPin); float celsius = convertToCelsius(value); float fahrenheit = convertFromCelsiusToFahrenheit(celsius); if(oldvalue != value) { lcd.cursorTo(1, 0); //line=2, x=0 lcd.printFloat(celsius,1); lcd.printIn("C "); lcd.printFloat(fahrenheit,1); lcd.printIn("F "); value = oldvalue; } if( (fahrenheit+0.01>=targetF) and (!targetreached) ){ targetreached = true; printTarget(); playSong(); loopcounter = 0; } else if( (targetreached) and (loopcounter % 100 == 0)) { // every ten seconds, check the status if(fahrenheit<targetF) { targetreached = false; printTarget(); } else playSong(); } } delay(100); }
static int play(char *fn) { int song; int maxlatency; DWORD threadId; strcpy(current_filename_with_song, fn); song = extractSongNumber(fn, current_filename); if (!loadModule(current_filename, module, &module_len)) return -1; if (!ASAP_Load(&asap, current_filename, module, module_len)) return 1; if (song < 0) song = asap.module_info.default_song; duration = playSong(song); maxlatency = mod.outMod->Open(ASAP_SAMPLE_RATE, channels, BITS_PER_SAMPLE, -1, -1); if (maxlatency < 0) return 1; mod.SetInfo(BITS_PER_SAMPLE, ASAP_SAMPLE_RATE / 1000, channels, 1); mod.SAVSAInit(maxlatency, ASAP_SAMPLE_RATE); // the order of VSASetInfo's arguments in in2.h is wrong! // http://forums.winamp.com/showthread.php?postid=1841035 mod.VSASetInfo(ASAP_SAMPLE_RATE, channels); mod.outMod->SetVolume(-666); seek_needed = -1; thread_run = TRUE; thread_handle = CreateThread(NULL, 0, playThread, NULL, 0, &threadId); if (playing_info) updateInfoDialog(current_filename, song); return thread_handle != NULL ? 0 : 1; }
static void createGameLayout( void ) { playSong( "Music/play.it" ); introMode = 0; resetEverything( ); Vector2 basePos = { 50.0f, 50.0f }; for( basePos.x = 50.0f; basePos.x < 1000.0f; basePos.x += 100.0f ) { for( basePos.y = 50.0f; basePos.y < 500.0f; basePos.y += 100.0f ) { float chance = randFloat( 0.0f, 1.0f ); chance -= CHANCE_OF_WIRE_GROUP; if( chance <= 0.0f ) { layWireGroup( basePos ); continue; } chance -= CHANCE_OF_MINE_GROUP; if( chance <= 0.0f ) { layMineGroup( basePos ); continue; } chance -= CHANCE_OF_PIT; if( chance <= 0.0f ) { layPit( basePos ); } } } }
static int play(char *fn) { char filename[MAX_PATH]; int song; const ASAPInfo *info; int channels; int maxlatency; DWORD threadId; strcpy(playing_filename_with_song, fn); song = extractSongNumber(fn, filename); if (!loadModule(filename, module, &module_len)) return -1; if (!ASAP_Load(asap, filename, module, module_len)) return 1; info = ASAP_GetInfo(asap); if (song < 0) song = ASAPInfo_GetDefaultSong(info); duration = playSong(song); channels = ASAPInfo_GetChannels(info); maxlatency = mod.outMod->Open(ASAP_SAMPLE_RATE, channels, BITS_PER_SAMPLE, -1, -1); if (maxlatency < 0) return 1; mod.SetInfo(BITS_PER_SAMPLE, ASAP_SAMPLE_RATE / 1000, channels, 1); mod.SAVSAInit(maxlatency, ASAP_SAMPLE_RATE); // the order of VSASetInfo's arguments in in2.h is wrong! // http://forums.winamp.com/showthread.php?postid=1841035 mod.VSASetInfo(ASAP_SAMPLE_RATE, channels); mod.outMod->SetVolume(-666); seek_needed = -1; thread_run = TRUE; thread_handle = CreateThread(NULL, 0, playThread, NULL, 0, &threadId); setPlayingSong(filename, song); return thread_handle != NULL ? 0 : 1; }
void Player::setFile(const QModelIndex & index) { if(!index.isValid()) return ; last = m_current; position = index.row(); m_current = (*myPlaylist)[position]; switch(selectedReadMode) { case ONEFILE: case SEQUENTIAL: { break; } case RANDOM: { m_positions.insert(++m_listposition,position); break; } } setTitle(m_current->getReadableTitle()); QMediaContent* source = playSong(m_current); m_mediaPlayer->setMedia(*source); m_mediaPlayer->play(); }
// Acts as a member function of a class void toggleSound() { soundOn = !soundOn; if (soundOn) //Default sound in main menu playSong(JAMES_BOND); else muteSounds(); }
void KSoundManager::update(float dt) { if(mSilent) return; mSystem->update(); if (fading) { musicFadeTimeCounter -= dt; if (musicFadeTimeCounter < 0) { printf("fade song to %s\n", nextSong.c_str()); stopSong(); if(nextSong != "") playSong(nextSong, mMusicVolume, 0); nextSong = ""; fading = false; musicFadeTimeCounter = 0.0; musicFadeTime = 0.0; } else { songChannel->setVolume(mMusicVolume * musicFadeTimeCounter/musicFadeTime); } } //if we have a play list...well, use it if(mUsePlayList && mPlayList.size()) { unsigned int trackTime = 0; if(songChannel) { bool playing; songChannel->isPlaying(&playing); if(!playing) mTrackTime = 99999; else { songChannel->getPosition(&trackTime, FMOD_TIMEUNIT_MS); mTrackTime = 0.001 * trackTime; } } else mTrackTime = 99999; //if the song stops, move on if(mTrackTime > mPlayList[mTrack].trackTime) skipSong(); } for(int i = 0; i < (int)mDelayedSounds.size(); i++) { mDelayedSounds[i].delay-= dt; if(mDelayedSounds[i].delay <= 0) { mDelayedSounds[i].sound->setPaused(false); mDelayedSounds[i] = mDelayedSounds.back(); mDelayedSounds.pop_back(); i--; } } }
void song::startExport() { stop(); playSong(); m_exporting = true; m_vstSyncController.setPlaybackState( true ); }
void SelectMidiOut::run( const sf::Window &app, linthesia::Context &context, const sf::Time &delta ) { if (isPlaying) { playSong(context, delta); } }
void Musec::on_btnPlay_clicked() { // Activate input if (!fIsActive) activateForm(); // Prevent difficulty cheating fDiffLock = slDifficulty->value(); playSong(); }
CInputDecoder * __cdecl Open(char *filename, int audioDataOffset) { BYTE module[ASAPInfo_MAX_MODULE_LENGTH]; int module_len; if (!loadModule(filename, module, &module_len)) return NULL; if (!ASAP_Load(asap, filename, module, module_len)) return NULL; playSong(ASAPInfo_GetDefaultSong(ASAP_GetInfo(asap))); return new CASAPDecoder(); }
CInputDecoder * __cdecl Open(char *filename, int audioDataOffset) { byte module[ASAP_MODULE_MAX]; int module_len; if (!loadModule(filename, module, &module_len)) return NULL; if (!ASAP_Load(&asap, filename, module, module_len)) return NULL; playSong(asap.module_info.default_song); return new CASAPDecoder(); }
int playTimes(char *song, int a) { // scope 6 int m; for (m = 0; m < a; m++) // scope 7 { int length = 4; playSong(song, length); } return a; }
QMediaContent* Player::playSong(PlaylistItem* p) { //QFile* file = new QFile(p->getURI()); if(QFile::exists(p->getURI())) { return new QMediaContent(QUrl::fromLocalFile(p->getURI())); } else { next(); return playSong(m_current); } }
static int gameOverScreen_Enter( void ) { timeAlive = 0.0f; cam_TurnOnFlags( 0, 1 ); cam_SetNextState( 0, VEC2_ZERO ); gfx_SetClearColor( CLR_BLACK ); if( !mute ) { playSong( "Music/game_over.it" ); } return 1; }
void SoundManager::update(float dt) {if(mSilent) return; mSystem->update(); if (fading && song) { musicFadeTimeCounter -= dt; if (musicFadeTimeCounter < 0) { stopSong(); if(nextSong != "") playSong(nextSong, 1, 0); nextSong = ""; fading = false; musicFadeTimeCounter = 0.0; musicFadeTime = 0.0; } else { songChannel->setVolume(mMusicVolume * musicFadeTimeCounter/musicFadeTime); } } //if we have a play list...well, use it if(mUsePlayList && mPlayList.size()) { unsigned int trackTime = 0; if(songChannel) { bool playing; songChannel->isPlaying(&playing); if(!playing) mTrackTime = 99999; else { songChannel->getPosition(&trackTime, FMOD_TIMEUNIT_MS); //if tracktime is zero and the last tracktime is also zero // if(mTrackTime == 0 && trackTime == 0) // mTrackTime = 9999; // else mTrackTime = 0.001 * trackTime; } } else mTrackTime = 99999; //if the song stops, move on // printf("%f/%f\n", mTrackTime, mPlayList[mTrack].trackTime); if(mTrackTime > mPlayList[mTrack].trackTime) skipSong(); } }
void AmigaSound::updateMusic() { if (_fanfareCount > 0) { --_fanfareCount; if (_fanfareCount == 0) { playSong(_fanfareRestore); } } if (_fluteCount > 0 && (_lastOverride == 40 || _lastOverride == 3)) { --_fluteCount; if (_fluteCount == 0) { playPattern("JUNG", 5 + _vm->randomizer.getRandomNumber(6)); _fluteCount = 100; } } }
//-------------------------------------------------------------- void testApp::update(){ howareyou.update(); menuNOSTALGIC.update(); menuINTROSPECTIVE.update(); menuLOST.update(); menuDETERMINED.update(); fadeOutVid.update(); updateVideos(); playSong(songMood); ofSoundUpdate(); if (fadeOutVid.getIsMovieDone()) { fadeOutVid.closeMovie(); switch (moodSelected) { case 1 : nostalgic[randomNostalgic].play(); nostalgic[randomNostalgic].setLoopState(OF_LOOP_NONE); break; case 2 : introspective[randomIntrospective].play(); introspective[randomIntrospective].setLoopState(OF_LOOP_NONE); break; case 3 : lost[randomLost].play(); lost[randomLost].setLoopState(OF_LOOP_NONE); break; case 4 : determined[randomDetermined].play(); determined[randomDetermined].setLoopState(OF_LOOP_NONE); break; } } }
void Song::startExport() { stop(); if(m_renderBetweenMarkers) { m_playPos[Mode_PlaySong].setTicks( m_playPos[Mode_PlaySong].m_timeLine->loopBegin().getTicks() ); } else { m_playPos[Mode_PlaySong].setTicks( 0 ); } playSong(); m_exporting = true; m_vstSyncController.setPlaybackState( true ); }
void SoundManager::skipSong() {if(mSilent) return; mTrack++; if(mTrack < 0) mTrack += mPlayList.size(); mTrack = (mTrack) % mPlayList.size(); mTrackTime = 0; float vol = 1; if(songChannel) { bool playing; songChannel->isPlaying(&playing); songChannel->getVolume(&vol); songChannel->stop(); } playSong(mPlayList[mTrack].filename, mMusicVolume, 0, false); printf("new song: %i: %s\n", mTrack, mPlayList[mTrack].filename.c_str() ); }
void Song::startExport() { stop(); if (m_renderBetweenMarkers) { m_exportSongBegin = m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin(); m_exportSongEnd = m_exportLoopEnd = m_playPos[Mode_PlaySong].m_timeLine->loopEnd(); m_playPos[Mode_PlaySong].setTicks( m_playPos[Mode_PlaySong].m_timeLine->loopBegin().getTicks() ); } else { m_exportSongEnd = MidiTime(m_length, 0); // Handle potentially ridiculous loop points gracefully. if (m_loopRenderCount > 1 && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() > m_exportSongEnd) { m_exportSongEnd = m_playPos[Mode_PlaySong].m_timeLine->loopEnd(); } if (!m_exportLoop) m_exportSongEnd += MidiTime(1,0); m_exportSongBegin = MidiTime(0,0); m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? m_playPos[Mode_PlaySong].m_timeLine->loopBegin() : MidiTime(0,0); m_exportLoopEnd = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? m_playPos[Mode_PlaySong].m_timeLine->loopEnd() : MidiTime(0,0); m_playPos[Mode_PlaySong].setTicks( 0 ); } m_exportEffectiveLength = (m_exportLoopBegin - m_exportSongBegin) + (m_exportLoopEnd - m_exportLoopBegin) * m_loopRenderCount + (m_exportSongEnd - m_exportLoopEnd); m_loopRenderRemaining = m_loopRenderCount; playSong(); m_exporting = true; m_vstSyncController.setPlaybackState( true ); }
static int gameScreen_Enter( void ) { cam_TurnOnFlags( 0, 1 ); SDL_ShowCursor( SDL_DISABLE ); setRendererClearColor( 0.878f, 0.807f, 0.667f, 1.0f ); resetEverything( ); sideCollisions[OUR_SIDE].type = CT_AABB; sideCollisions[OUR_SIDE].aabb.center.x = 500.0f; sideCollisions[OUR_SIDE].aabb.center.y = 600.0f + 10.0f; sideCollisions[OUR_SIDE].aabb.halfDim.x = 1000.0f; sideCollisions[OUR_SIDE].aabb.halfDim.y = 10.0f; sideCollisions[THEIR_SIDE].type = CT_AABB; sideCollisions[THEIR_SIDE].aabb.center.x = 500.0f; sideCollisions[THEIR_SIDE].aabb.center.y = -10.0f; sideCollisions[THEIR_SIDE].aabb.halfDim.x = 1000.0f; sideCollisions[THEIR_SIDE].aabb.halfDim.y = 10.0f; sideCollisions[LEFT_SIDE].type = CT_AABB; sideCollisions[LEFT_SIDE].aabb.center.x = -10.0f; sideCollisions[LEFT_SIDE].aabb.center.y = 300.0f; sideCollisions[LEFT_SIDE].aabb.halfDim.x = 10.0f; sideCollisions[LEFT_SIDE].aabb.halfDim.y = 1000.0f; sideCollisions[RIGHT_SIDE].type = CT_AABB; sideCollisions[RIGHT_SIDE].aabb.center.x = 1000.0f + 10.0f; sideCollisions[RIGHT_SIDE].aabb.center.y = 300.0f; sideCollisions[RIGHT_SIDE].aabb.halfDim.x = 10.0f; sideCollisions[RIGHT_SIDE].aabb.halfDim.y = 1000.0f; sideColliders.firstCollider = sideCollisions; sideColliders.count = 4; sideColliders.stride = sizeof( union Collider ); //createGameLayout( ); createIntroLayout( ); playSong( "Music/intro.it" ); return 1; }
void MusicPlayer::playList() { if(!playlistIsEmpty()) { while(1) { playOrPause = 1; playingState = PS_PLAY; unsigned int songindex = spl.songIndex[spl.currentSongNum]; playSong(songindex); switch(playingState) { case PS_STOP: playOrPause = 0;GREEN_LED_OFF();return; case PS_NEXT_SONG: if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum); else if(spl.currentSongNum == spl.songTotalNum - 1) spl.currentSongNum = 0; else ++ spl.currentSongNum; playOrPause = 1; break; case PS_PREVIOUS_SONG:if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum); else if(spl.currentSongNum == 0) spl.currentSongNum = spl.songTotalNum - 1; else -- spl.currentSongNum; playOrPause = 1; break; default: if(_playmode == MODE_SHUFFLE) spl.currentSongNum = random(0,spl.songTotalNum); else if(_playmode == MODE_NORMAL) { if(spl.currentSongNum == spl.songTotalNum - 1) { playingState = PS_STOP; return; } else spl.currentSongNum ++; } else if(_playmode == MODE_REPEAT_LIST) { if(spl.currentSongNum == spl.songTotalNum - 1) spl.currentSongNum = 0; else spl.currentSongNum++; } break; } } } }
void Player::decreaseSong(int i) { QMediaContent* source = NULL; int pos = playListItem2Index(m_current); pos-=i; if(pos<0) { pos=0; } m_current = (*myPlaylist)[pos]; source = playSong(m_current); if(m_current!=NULL) setTitle(m_current->getReadableTitle()); m_mediaPlayer->setMedia(*source); m_mediaPlayer->play(); }
void SearchWidget::finishGetSongUrl(QNetworkReply *reply) { if(reply->error() == QNetworkReply::NoError) { QString text = reply->readAll(); QScriptEngine engine; QScriptValue sv = engine.evaluate("value=" + text); if(sv.property("status").toInt32() == 1) { QString songurl = sv.property("url").toString(); qDebug()<<songurl; if(state == Play) playSong(songurl); if(state == Download) downloadFile(songurl); downloadSong(songurl); } } state = -1; }
int rowTutor::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: playSong(); break; case 1: stopSong(); break; case 2: playTutorSong((*reinterpret_cast< QList<char>(*)>(_a[1]))); break; case 3: playNoteGUI((*reinterpret_cast< char(*)>(_a[1]))); break; case 4: noteCDown(); break; case 5: noteDDown(); break; case 6: noteEDown(); break; case 7: noteFDown(); break; case 8: noteGDown(); break; case 9: noteHiCDown(); break; case 10: key1(); break; case 11: key2(); break; case 12: key3(); break; case 13: key4(); break; case 14: key5(); break; case 15: key6(); break; case 16: key7(); break; case 17: key8(); break; case 18: key9(); break; case 19: key10(); break; case 20: key11(); break; case 21: key12(); break; case 22: key13(); break; case 23: key14(); break; case 24: key15(); break; case 25: key16(); break; case 26: key17(); break; case 27: key18(); break; default: ; } _id -= 28; } return _id; }
void SoundManager::update(){ while (m_eventHandler.hasEvents()) { //cout << "Handling event from SM!\n"; Event* currentEvent = m_eventHandler.getTopEvent(); if (currentEvent->getEventName() == string("play_sound")){ string argument = (*currentEvent->getArguments())[0]; playSound(argument); } if (currentEvent->getEventName() == string("play_song")){ string argument = (*currentEvent->getArguments())[0]; playSong(argument); } if (currentEvent->getEventName() == string("song_volume")){ string argument = (*currentEvent->getArguments())[0]; setSongVolume(atoi(argument.c_str())); } } }
void song::playAndRecord() { playSong(); m_recording = true; }