コード例 #1
0
// ----------------------------------------------------------------------------
//
void SpotifyEngine::previousTrack()
{
    CSingleLock lock( &m_mutex, TRUE );

    if ( m_current_track && getTrackPlayTime() > 10*1000 ) {    // If current track > 10 seconds in, return to start
        if ( m_track_played_queue.size() )
            m_track_played_queue.pop_back();

        playTrack( m_current_track, 0L ); 
    }
    else if ( m_track_played_queue.size() ) {
        if ( m_current_track ) {                                // Skip over currently playing track (re-queue it)
            TrackQueueEntry track = m_track_played_queue.back();
            m_track_played_queue.pop_back();
            m_track_queue.push_front( track );
        }

        if ( m_track_played_queue.size() ) {
            TrackQueueEntry track = m_track_played_queue.back();
            m_track_played_queue.pop_back();
            playTrack( track.m_track, 0L ); 
        }
        else {                                                  // Current track was the only track in the played queue
            stopTrack();

            sendTrackQueueEvent();
        }
    }
}
コード例 #2
0
void SoundTowns_Darkmoon::playSoundEffect(uint8 track, uint8 volume) {
	if (!_sfxEnabled)
		return;

	if (volume == 255)
		return playTrack(track);

	uint8 *pcm = 0;

	switch (_soundTable[track].type) {
	case 0:
		if (_soundTable[track].para1 == -1 || (uint32)_soundTable[track].para1 > _pcmDataSize)
			return;

		pcm = _pcmData + _soundTable[track].para1;
		WRITE_LE_UINT16(&pcm[24], _soundTable[track].para2 * 98 / 1000);

		_intf->callback(39, 0x47);
		_intf->callback(37, 0x47, 60, volume, pcm);
		break;

	case 3:
		_intf->callback(2, _lastEnvChan);
		_intf->callback(4, _lastEnvChan, _soundTable[track].para1);
		_intf->callback(1, _lastEnvChan, _soundTable[track].para2, volume);
		break;

	default:
		break;
	}

	if (++_lastEnvChan == 0x43)
		_lastEnvChan = 0x40;
}
コード例 #3
0
ファイル: animatedsprite.cpp プロジェクト: budsan/Skaflonker
bool AnimatedSprite::playTrack(const std::string &name)
{
	if (m_lib == nullptr)
		return false;

	std::size_t animID = trackID(name);
	return playTrack(animID);
}
コード例 #4
0
ファイル: Tune.cpp プロジェクト: Snootlab/Tune
void Tune::playPlaylist(int start, int end)
{
	for (int i=start; i<=end; i++)
	{
		playTrack(i);
		while(isPlaying()) delay(1); // experimentally found that the small delay made it work
	}
}
コード例 #5
0
ファイル: plistsgroup.cpp プロジェクト: Nerobrain/pulsar
void PlistsGroup::prevTrack()
{
    if(!m_TracksHistory.isEmpty()) {
        Track *p = m_TracksHistory.pop();
        m_LastList = (Playlist *)p->parent();
        Q_EMIT playTrack(p);
    }
}
コード例 #6
0
ファイル: animatedsprite.cpp プロジェクト: budsan/Skaflonker
bool AnimatedSprite::ensureTrack(const std::string &name)
{
	if (m_lib == nullptr)
		return false;

	std::size_t animID = trackID(name);
	if (animID != m_currentTrack)
		return playTrack(animID);

	return true;
}
コード例 #7
0
ファイル: player.cpp プロジェクト: Nerobrain/pulsar
void Player::trackUpdated(bool s)
{
    if(s) {
        if(m_Current) {
            playTrack(m_Current);
            Q_EMIT changed();
            if(m_bBroadcastStatus)
                m_VkActions->setStatus(m_Current);
        }
    } else {
        Q_EMIT needTrack();
    }
}
コード例 #8
0
ファイル: plistsgroup.cpp プロジェクト: Nerobrain/pulsar
void PlistsGroup::nextTrack()
{
    // If queue list is not empty, take track from queue
    if(m_TracksQueue.isEmpty()) {
        if(m_LastList) {
            if(m_repeatMode == 2 && m_LastTrack) {
                // Emit play action to player object
                Q_EMIT playTrack(m_LastTrack);

                // Simulate track activate for set last list pointer
                trackActivate(m_LastTrack);
            } else {
                if(m_shuffleMode == 3)
                    m_playLists.at(qrand() % m_playLists.size())->nextTrack();
                else
                    m_LastList->nextTrack();
            }
        } else {
            m_playLists.first()->nextTrack();
        }

    } else {
        Track *p = m_TracksQueue.dequeue();

        // Emit play action to player object
        Q_EMIT playTrack(p);

        // Simulate track activate for set last list pointer
        trackActivate(p);

        // Update numbers on queued tracks
        for(int i = 0; i < m_TracksQueue.size(); i++) {
            m_TracksQueue.at(i)->setToQueue(i+1);
        }
    }
}
コード例 #9
0
ClientResponse* SpotifyPlaylistContainer::processTask(PlaylistTask* task) {
	switch (task->getCommand()) {
	case CommandList:
		return listPlaylists(task);
		break;
	case CommandPlayPlaylist:
		return playPlaylist(task);
		break;
	case CommandPlayTrack:
		return playTrack(task);
		break;
	case CommandListTracks:
		return listTracks(task);
		break;
	}
	return nullptr;
}
コード例 #10
0
ファイル: player.cpp プロジェクト: Nerobrain/pulsar
void Player::setTrack(Track *p)
{
    if(m_Current) {
        m_Prev = m_Current;
        connect(m_Prev, SIGNAL(destroyed()), SLOT(onPrevDeleted()));
    }

    if(m_Prev) {
        m_Prev->setDefaultState();
        disconnect(m_Prev, SIGNAL(updated(bool)), this, SLOT(trackUpdated(bool)));
        m_Prev->setLast(false);
    }

    m_Current = p;
    connect(m_Current, SIGNAL(destroyed()), SLOT(prevDeleted()));

    m_Current->setLast(true);

    if(m_Current->url().isEmpty()) {
        m_Current->updateUrl();
        connect(m_Current, SIGNAL(updated(bool)), SLOT(trackUpdated(bool)));
    } else {
        playTrack(m_Current);
    }

    if(m_bBroadcastStatus)
        m_VkActions->setStatus(m_Current);

    // Meta
    if(m_Current->metaLoaded()) {
        Q_EMIT metaChanged();

        QString artStr;
        if(!m_bArtRequested && !m_Current->metaAlbum().isEmpty()) {
            artStr = m_Current->metaArtist() + " " + m_Current->metaAlbum();
            Q_EMIT loadArt(artStr);
            m_bArtRequested = true;
        }
    }

}
コード例 #11
0
ファイル: animatedsprite.cpp プロジェクト: budsan/Skaflonker
bool AnimatedSprite::setLibrary(std::shared_ptr<Library> _data)
{
	if (_data == nullptr)
	{
		m_lib.reset();
		return true;
	}

	if (_data->tracks.size() == 0)
		return false;

	m_lib = _data;
	if (!playTrack(0)) {
		m_lib.reset();
		return false;
	}

	//    m_idleTrack = trackID("idle");

	return true;
}
コード例 #12
0
void SoundAmiga::playSoundEffect(uint8 track, uint8) {
	debugC(5, kDebugLevelSound, "SoundAmiga::playSoundEffect(%d)", track);
	const AmigaSfxTable *sfx = 0;
	bool pan = false;

	switch (_fileLoaded) {
	case kFileFinal:
	case kFileIntro:
		// We only allow playing of sound effects, which are included in the table.
		if (track < _tableSfxIntro_Size) {
			sfx = &_tableSfxIntro[track];
			pan = (sfx->pan != 0);
		}
		break;

	case kFileGame:
		if (0x61 <= track && track <= 0x63)
			playTrack(track - 0x4F);

		if (track >= _tableSfxGame_Size)
			return;

		if (_tableSfxGame[track].note) {
			sfx = &_tableSfxGame[track];
			pan = (sfx->pan != 0) && (sfx->pan != 2);
		}

		break;

	default:
		return;
	}

	if (_sfxEnabled && sfx) {
		const bool success = _driver->playNote(sfx->note, sfx->patch, sfx->duration, sfx->volume, pan);
		if (success && !_mixer->isSoundHandleActive(_musicHandle))
			_mixer->playStream(Audio::Mixer::kPlainSoundType, &_musicHandle, _driver, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
	}
}
コード例 #13
0
ファイル: Bodyseq.cpp プロジェクト: VSIONHAIRIES/CFO-Modular
void Bodyseq::update() {
    buttons.read();
    keypads.read();
    updatePosition();
    pots.update();

    switch(mode) {
        case 0:                 // NO_BUTTONS
            playTrack();
            break;
        case 1:                 // BUTTON_1
            selectNote();
            break;
        case 2:                 // BUTTON_2
            selectStep();
            break;
        case 3:                 // BUTTON_1_2
            selectOctave();
            break;
        case 4:                 // BUTTON_3
            selectTrack();
            break;
        case 5:                 // BUTTON_1_3
            chainTrack();
            break;
        case 6:                 // BUTTON_2_3
            copyTrack();
            break;
        case 7:                 // BUTTON_1_2_3
            clearTrack();
            break;
        default:
            break;
    }
    leds.update();
}
コード例 #14
0
ファイル: playlist.cpp プロジェクト: Nerobrain/pulsar
void Playlist::playLast()
{
    if(m_LastTrack)
        Q_EMIT playTrack(m_LastTrack);
}
コード例 #15
0
ファイル: main.cpp プロジェクト: Daivuk/PatateQuest
int main()
{
    //Instruments instruments = {
    //    {8, {{8}, {7}, {6}, {5}, {4}, {3}, {2}, {1}}}, // 0
    //    {-100, {{8}}}, // 1
    //    {0, {{8}, {6}, {4}, {2}}}, // 2
    //    {0, {{8}, {4}}}, // 3
    //};
    /*
    auto track = buildTrack(instruments, 8, {
        NOTE(C4, 0, 8), NOTE(C3, 0, 8), NOTE(G2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(C4, 0, 8), ____, NOTE(C3, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(G4, 0, 8), NOTE(C3, 0, 8), NOTE(E3, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(G4, 0, 8), ____, NOTE(C3, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(A4, 0, 8), NOTE(C3, 0, 8), NOTE(A2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(A4, 0, 8), ____, NOTE(C3, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(G4, 0, 8), NOTE(G3, 0, 8), NOTE(G2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        ____, ____, NOTE(B2, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, NOTE(C6, 3, 15),
        NOTE(F4, 0, 8), NOTE(A3, 0, 8), NOTE(A2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(F4, 0, 8), ____, NOTE(C3, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(E4, 0, 8), NOTE(A3, 0, 8), NOTE(E3, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(E4, 0, 8), ____, FULL(C3, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(D4, 0, 8), NOTE(G3, 0, 8), NOTE(G2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        NOTE(D4, 0, 8), ____, FULL(B2, 1, 15), NOTE(C6, 3, 15),
        ____, ____, ____, ____,
        NOTE(C4, 0, 8), NOTE(C3, 0, 8), NOTE(G2, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, ____,
        ____, ____, NOTE(C3, 1, 15), NOTE(C4, 2, 15),
        ____, ____, ____, NOTE(C6, 3, 15),
    });*/

    Instruments instruments = {
        //{-1000, {{8}}}, // 2
        //{-1000, {{8}}}, // 2
        //{-1000, {{8}}}, // 2
        //{-1000, {{8}}}, // 2
        {48,
        {{8}, {8}, {8}, {8}, {8}, {8},
        {7}, {7}, {7}, {7}, {7}, {7},
        {6}, {6}, {6}, {6}, {6}, {6},
        {5}, {5}, {5}, {5}, {5}, {5},
        {4}, {4}, {4}, {4}, {4}, {4},
        {3}, {3}, {3}, {3}, {3}, {3},
        {2}, {2}, {2}, {2}, {2}, {2},
        {1}, {1}, {1}, {1}, {1}, {1}}}, // 0

        {48,
        {{8}, {8}, {8}, {8}, {8}, {8},
        {7}, {7}, {7}, {7}, {7}, {7},
        {6}, {6}, {6}, {6}, {6}, {6},
        {5}, {5}, {5}, {5}, {5}, {5},
        {4}, {4}, {4}, {4}, {4}, {4},
        {3}, {3}, {3}, {3}, {3}, {3},
        {2}, {2}, {2}, {2}, {2}, {2},
        {1}, {1}, {1}, {1}, {1}, {1}}}, // 0

        //{8, {{8}, {7}, {6}, {5}, {4}, {3}, {2}, {1}}}, // 1
        {-10000, {{8}}}, // 2

        {12,
        {{8},
        {7}, {7}, {7}, 
        {6}, {6}, {6}, 
        {5}, {5}, {5}, 
        {4}, {4}, {4}, 
        {3}, {3}, {3}, 
        {2}, {2}, {2}, 
        {1}, {1}, {1}, }}, // 0
        //{-10000, {{8}}}, // 2
        //{0, {{8}, {6}, {4}, {2}}}, // 3
        //{0, {{8}, {4}}}, // 3
    };

    auto trackFrames = buildTrackFramesFromMidi("faxanadu.mid");
    auto track = buildTrack(instruments, 1, trackFrames);

    playTrack(track);

    return 0;
}
コード例 #16
0
void SoundCloudPlaylistWindow::loadBaseUi() {
    setWindowTitle(tr("Set"));
    setCentralWidget(new QWidget);
    
    m_view->setModel(m_model);
    m_view->setItemDelegate(m_delegate);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    
    m_thumbnail->setFixedSize(320, 320);
    m_thumbnail->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/295x295/hildon/mediaplayer_default_album.png"));
    m_avatar->setFixedSize(60, 60);
    m_avatar->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/64x64/hildon/general_default_avatar.png"));
    
    m_titleLabel->setWordWrap(true);
    m_dateLabel->setStyleSheet(QString("color: %1; font-size: 13pt").arg(palette().color(QPalette::Mid).name()));
    m_artistLabel->setStyleSheet("font-size: 13pt");
    m_noTracksLabel->hide();

    m_reloadAction->setEnabled(false);
    
    m_contextMenu->addAction(m_queueAction);
    m_contextMenu->addAction(m_downloadAction);
    m_contextMenu->addAction(m_shareAction);
    
    QWidget *scrollWidget = new QWidget(m_scrollArea);
    QGridLayout *grid = new QGridLayout(scrollWidget);
    grid->addWidget(m_thumbnail, 0, 0, 1, 2, Qt::AlignLeft);
    grid->addWidget(m_titleLabel, 1, 0, 1, 2);
    grid->addWidget(m_avatar, 2, 0, 2, 1, Qt::AlignLeft);
    grid->addWidget(m_artistLabel, 2, 1, Qt::AlignLeft | Qt::AlignTop);
    grid->addWidget(m_dateLabel, 3, 1, Qt::AlignLeft | Qt::AlignBottom);
    grid->addWidget(m_descriptionLabel, 4, 0, 1, 2);
    grid->setRowStretch(4, 1);
    grid->setColumnStretch(1, 1);
    grid->setContentsMargins(0, 0, 0, 0);
    m_scrollArea->setWidget(scrollWidget);
    m_scrollArea->setWidgetResizable(true);
    m_scrollArea->setFixedWidth(330);
    
    m_layout = new QHBoxLayout(centralWidget());
    m_layout->addWidget(m_scrollArea);
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_noTracksLabel);
    m_layout->setStretch(1, 1);
    m_layout->setStretch(2, 1);
    m_layout->setContentsMargins(0, 0, 0, 0);

    menuBar()->addAction(m_reloadAction);
    menuBar()->addAction(m_queuePlaylistAction);
    menuBar()->addAction(m_nowPlayingAction);
    
    connect(m_model, SIGNAL(statusChanged(QSoundCloud::ResourcesRequest::Status)), this,
            SLOT(onModelStatusChanged(QSoundCloud::ResourcesRequest::Status)));
    connect(m_cache, SIGNAL(imageReady()), this, SLOT(onImageReady()));
    connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(showTrack(QModelIndex)));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_thumbnail, SIGNAL(clicked()), this, SLOT(playPlaylist()));
    connect(m_delegate, SIGNAL(thumbnailClicked(QModelIndex)), this, SLOT(playTrack(QModelIndex)));
    connect(m_reloadAction, SIGNAL(triggered()), m_model, SLOT(reload()));
    connect(m_queuePlaylistAction, SIGNAL(triggered()), this, SLOT(queuePlaylist()));
    connect(m_avatar, SIGNAL(clicked()), this, SLOT(showArtist()));
    connect(m_descriptionLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(showResource(QUrl)));
    connect(m_queueAction, SIGNAL(triggered()), this, SLOT(queueTrack()));
    connect(m_downloadAction, SIGNAL(triggered()), this, SLOT(downloadTrack()));
    connect(m_shareAction, SIGNAL(triggered()), this, SLOT(shareTrack()));
    
    if (!SoundCloud::instance()->userId().isEmpty()) {
        m_favouriteAction = new QAction(this);
        m_contextMenu->addAction(m_favouriteAction);
        connect(m_favouriteAction, SIGNAL(triggered()), this, SLOT(setTrackFavourite()));
    }
}