本文整理汇总了C++中Hydrogen::getState方法的典型用法代码示例。如果您正苦于以下问题:C++ Hydrogen::getState方法的具体用法?C++ Hydrogen::getState怎么用?C++ Hydrogen::getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hydrogen
的用法示例。
在下文中一共展示了Hydrogen::getState方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_songLoadAction
void SoundLibraryPanel::on_songLoadAction()
{
QString songName = __sound_library_tree->currentItem()->text( 0 );
QString sDirectory = Preferences::get_instance()->getDataDirectory() + "songs";
QString sFilename = sDirectory + "/" + songName + ".h2song";
Hydrogen *engine = Hydrogen::get_instance();
if ( engine->getState() == STATE_PLAYING ) {
engine->sequencer_stop();
}
Song *pSong = Song::load( sFilename );
if ( pSong == NULL ) {
QMessageBox::information( this, "Hydrogen", trUtf8("Error loading song.") );
return;
}
// add the new loaded song in the "last used song" vector
Preferences *pPref = Preferences::get_instance();
std::vector<QString> recentFiles = pPref->getRecentFiles();
recentFiles.insert( recentFiles.begin(), sFilename );
pPref->setRecentFiles( recentFiles );
HydrogenApp* h2app = HydrogenApp::get_instance();
h2app->setSong( pSong );
//updateRecentUsedSongList();
engine->setSelectedPatternNumber( 0 );
}
示例2: action_file_new
void MainForm::action_file_new()
{
Hydrogen * pEngine = Hydrogen::get_instance();
if ( (pEngine->getState() == STATE_PLAYING) ) {
pEngine->sequencer_stop();
}
bool proceed = handleUnsavedChanges();
if(!proceed) {
return;
}
h2app->m_undoStack->clear();
pEngine->getTimeline()->m_timelinevector.clear();
Song * pSong = Song::get_empty_song();
pSong->set_filename( "" );
h2app->setSong(pSong);
pEngine->setSelectedPatternNumber( 0 );
h2app->getInstrumentRack()->getSoundLibraryPanel()->update_background_color();
h2app->getSongEditorPanel()->updatePositionRuler();
pEngine->getTimeline()->m_timelinetagvector.clear();
// update director tags
EventQueue::get_instance()->push_event( EVENT_METRONOME, 2 );
// update director songname
EventQueue::get_instance()->push_event( EVENT_METRONOME, 3 );
}
示例3: loadSong
/* This method is called by Event dispacher thread ( GUI ) */
bool Playlist::loadSong (int songNumber)
{
Hydrogen* pHydrogen = Hydrogen::get_instance();
Preferences *pPref = Preferences::get_instance();
if ( pHydrogen->getState() == STATE_PLAYING )
pHydrogen->sequencer_stop();
/* Load Song from file */
QString selected = pHydrogen->m_PlayList[ songNumber ].m_hFile;
Song *pSong = Song::load( selected );
if ( ! pSong ) return false;
setSelectedSongNr( songNumber );
setActiveSongNumber( songNumber );
pHydrogen->setSong( pSong );
pPref->setLastSongFilename( pSong->get_filename() );
vector<QString> recentFiles = pPref->getRecentFiles();
recentFiles.insert( recentFiles.begin(), selected );
pPref->setRecentFiles( recentFiles );
execScript( songNumber );
return true;
}
示例4: action_file_save_as
void MainForm::action_file_save_as()
{
Hydrogen* pEngine = Hydrogen::get_instance();
if ( pEngine->getState() == STATE_PLAYING ) {
pEngine->sequencer_stop();
}
//std::auto_ptr<QFileDialog> fd( new QFileDialog );
QFileDialog fd(this);
fd.setFileMode( QFileDialog::AnyFile );
fd.setFilter( trUtf8("Hydrogen Song (*.h2song)") );
fd.setAcceptMode( QFileDialog::AcceptSave );
fd.setWindowTitle( trUtf8( "Save song" ) );
fd.setSidebarUrls( fd.sidebarUrls() << QUrl::fromLocalFile( Filesystem::songs_dir() ) );
Song *song = pEngine->getSong();
QString defaultFilename;
QString lastFilename = song->get_filename();
if ( lastFilename.isEmpty() ) {
defaultFilename = pEngine->getSong()->__name;
defaultFilename += ".h2song";
}
else {
defaultFilename = lastFilename;
}
fd.selectFile( defaultFilename );
QString filename;
if (fd.exec() == QDialog::Accepted) {
filename = fd.selectedFiles().first();
}
if ( !filename.isEmpty() ) {
QString sNewFilename = filename;
if ( sNewFilename.endsWith(".h2song") == false ) {
filename += ".h2song";
}
song->set_filename(filename);
action_file_save();
}
h2app->setScrollStatusBarMessage( trUtf8("Song saved as.") + QString(" Into: ") + defaultFilename, 2000 );
h2app->updateWindowTitle();
}
示例5: nodePlayBTN
void PlaylistDialog::nodePlayBTN( Button* ref )
{
Hydrogen *pEngine = Hydrogen::get_instance();
HydrogenApp *pH2App = HydrogenApp::get_instance();
if (ref->isPressed()) {
QTreeWidgetItem* m_pPlaylistItem = m_pPlaylistTree->currentItem();
if ( m_pPlaylistItem == NULL ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No valid song selected!" ) );
m_pPlayBtn->setPressed(false);
return;
}
QString selected = "";
selected = m_pPlaylistItem->text ( 0 );
if( selected == pEngine->getSong()->get_filename()){
pEngine->sequencer_play();
return;
}
if ( pEngine->getState() == STATE_PLAYING ){
pEngine->sequencer_stop();
}
Song *pSong = Song::load ( selected );
if ( pSong == NULL ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Error loading song." ) );
m_pPlayBtn->setPressed(false);
return;
}
QTreeWidget* m_pPlaylist = m_pPlaylistTree;
int index = m_pPlaylist->indexOfTopLevelItem ( m_pPlaylistItem );
Playlist::get_instance()->setActiveSongNumber( index );
pH2App->setSong ( pSong );
pEngine->setSelectedPatternNumber ( 0 );
pEngine->sequencer_play();
}else
{
pEngine->sequencer_stop();
pH2App->setStatusBarMessage(trUtf8("Pause."), 5000);
}
}
示例6: handleAction
/**
* The handleAction method is the heard of the MidiActionManager class.
* It executes the operations that are needed to carry the desired action.
*/
bool MidiActionManager::handleAction( MidiAction * pAction ){
Hydrogen *pEngine = Hydrogen::get_instance();
/*
return false if action is null
(for example if no Action exists for an event)
*/
if( pAction == NULL ) return false;
QString sActionString = pAction->getType();
if( sActionString == "PLAY" )
{
int nState = pEngine->getState();
if ( nState == STATE_READY ){
pEngine->sequencer_play();
}
return true;
}
if( sActionString == "PLAY/STOP_TOGGLE" || sActionString == "PLAY/PAUSE_TOGGLE" )
{
int nState = pEngine->getState();
switch ( nState )
{
case STATE_READY:
pEngine->sequencer_play();
break;
case STATE_PLAYING:
if( sActionString == "PLAY/STOP_TOGGLE" ) pEngine->setPatternPos( 0 );
pEngine->sequencer_stop();
pEngine->setTimelineBpm();
break;
default:
ERRORLOG( "[Hydrogen::ActionManager(PLAY): Unhandled case" );
}
return true;
}
if( sActionString == "PAUSE" )
{
pEngine->sequencer_stop();
return true;
}
if( sActionString == "STOP" )
{
pEngine->sequencer_stop();
pEngine->setPatternPos( 0 );
pEngine->setTimelineBpm();
return true;
}
if( sActionString == "MUTE" ){
//mutes the master, not a single strip
pEngine->getSong()->__is_muted = true;
return true;
}
if( sActionString == "UNMUTE" ){
pEngine->getSong()->__is_muted = false;
return true;
}
if( sActionString == "MUTE_TOGGLE" ){
pEngine->getSong()->__is_muted = !Hydrogen::get_instance()->getSong()->__is_muted;
return true;
}
if( sActionString == "BEATCOUNTER" ){
pEngine->handleBeatCounter();
return true;
}
if( sActionString == "TAP_TEMPO" ){
pEngine->onTapTempoAccelEvent();
return true;
}
if( sActionString == "SELECT_NEXT_PATTERN" ){
bool ok;
int row = pAction->getParameter1().toInt(&ok,10);
if( row> pEngine->getSong()->get_pattern_list()->size() -1 )
return false;
if(Preferences::get_instance()->patternModePlaysSelected())
pEngine->setSelectedPatternNumber( row );
else
pEngine->sequencer_setNextPattern( row, false, true );
return true;
}
//.........这里部分代码省略.........
示例7: main
//.........这里部分代码省略.........
if ( drumkitInfo ) {
pHydrogen->loadDrumkit( drumkitInfo );
} else {
___ERRORLOG ( "Error loading the drumkit" );
}
}
AudioEngine* AudioEngine = AudioEngine::get_instance();
Sampler* sampler = AudioEngine->get_sampler();
switch ( interpolation ) {
case 1:
sampler->setInterpolateMode( Sampler::COSINE );
break;
case 2:
sampler->setInterpolateMode( Sampler::THIRD );
break;
case 3:
sampler->setInterpolateMode( Sampler::CUBIC );
break;
case 4:
sampler->setInterpolateMode( Sampler::HERMITE );
break;
case 0:
default:
sampler->setInterpolateMode( Sampler::LINEAR );
}
EventQueue *pQueue = EventQueue::get_instance();
signal(SIGINT, signal_handler);
bool ExportMode = false;
if ( ! outFilename.isEmpty() ) {
pHydrogen->startExportSong ( outFilename, rate, bits );
cout << "Export Progress ... ";
bool ExportMode = true;
}
// Interactive mode
while ( ! quit ) {
/* FIXME: Someday here will be The Real CLI ;-) */
Event event = pQueue->pop_event();
// if ( event.type > 0) cout << "EVENT TYPE: " << event.type << endl;
/* Event handler */
switch ( event.type ) {
case EVENT_PROGRESS: /* event used only in export mode */
if ( ! ExportMode ) break;
if ( event.value < 100 ) {
cout << "\rExport Progress ... " << event.value << "%";
} else {
cout << "\rExport Progress ... DONE" << endl;
quit = true;
}
break;
case EVENT_PLAYLIST_LOADSONG: /* Load new song on MIDI event */
if ( pPlaylist->loadSong ( event.value ) ) {
pSong = pHydrogen->getSong();
show_playlist ( pHydrogen, pPlaylist->getActiveSongNumber() );
}
break;
case EVENT_NONE: /* Sleep if there is no more events */
Sleeper::msleep ( 100 );
break;
}
}
if ( pHydrogen->getState() == STATE_PLAYING )
pHydrogen->sequencer_stop();
delete pSong;
delete pPlaylist;
delete pQueue;
delete pHydrogen;
delete preferences;
delete AudioEngine;
delete MidiMap::get_instance();
delete MidiActionManager::get_instance();
___INFOLOG( "Quitting..." );
delete Logger::get_instance();
int nObj = Object::objects_count();
if (nObj != 0) {
cerr << "\n\n\n " << nObj << " alive objects\n\n" << endl << endl;
Object::write_objects_map_to_cerr();
}
}
catch ( const H2Exception& ex ) {
cerr << "[main] Exception: " << ex.what() << endl;
}
catch (...) {
cerr << "[main] Unknown exception X-(" << endl;
}
return 0;
}
示例8: setPlayingNotelength
void Sampler::setPlayingNotelength( Instrument* instrument, unsigned long ticks, unsigned long noteOnTick )
{
if ( instrument ) { // stop all notes using this instrument
Hydrogen *pEngine = Hydrogen::get_instance();
Song* mSong = pEngine->getSong();
int selectedpattern = pEngine->__get_selected_PatterNumber();
Pattern* currentPattern = NULL;
if ( mSong->get_mode() == Song::PATTERN_MODE ||
( pEngine->getState() != STATE_PLAYING )){
PatternList *pPatternList = mSong->get_pattern_list();
if ( ( selectedpattern != -1 )
&& ( selectedpattern < ( int )pPatternList->size() ) ) {
currentPattern = pPatternList->get( selectedpattern );
}
}else
{
std::vector<PatternList*> *pColumns = mSong->get_pattern_group_vector();
// Pattern *pPattern = NULL;
int pos = pEngine->getPatternPos() +1;
for ( int i = 0; i < pos; ++i ) {
PatternList *pColumn = ( *pColumns )[i];
currentPattern = pColumn->get( 0 );
}
}
if ( currentPattern ) {
int patternsize = currentPattern->get_length();
for ( unsigned nNote = 0; nNote < currentPattern->get_length(); nNote++ ) {
const Pattern::notes_t* notes = currentPattern->get_notes();
FOREACH_NOTE_CST_IT_BOUND(notes,it,nNote) {
Note *pNote = it->second;
if ( pNote!=NULL ) {
if( !Preferences::get_instance()->__playselectedinstrument ){
if ( pNote->get_instrument() == instrument
&& pNote->get_position() == noteOnTick ) {
AudioEngine::get_instance()->lock( RIGHT_HERE );
if ( ticks > patternsize )
ticks = patternsize - noteOnTick;
pNote->set_length( ticks );
Hydrogen::get_instance()->getSong()->__is_modified = true;
AudioEngine::get_instance()->unlock(); // unlock the audio engine
}
}else
{
if ( pNote->get_instrument() == pEngine->getSong()->get_instrument_list()->get( pEngine->getSelectedInstrumentNumber())
&& pNote->get_position() == noteOnTick ) {
AudioEngine::get_instance()->lock( RIGHT_HERE );
if ( ticks > patternsize )
ticks = patternsize - noteOnTick;
pNote->set_length( ticks );
Hydrogen::get_instance()->getSong()->__is_modified = true;
AudioEngine::get_instance()->unlock(); // unlock the audio engine
}
}
}
}
}
}
}
示例9: __render_note
/// Render a note
/// Return 0: the note is not ended
/// Return 1: the note is ended
unsigned Sampler::__render_note( Note* pNote, unsigned nBufferSize, Song* pSong )
{
//infoLog( "[renderNote] instr: " + pNote->getInstrument()->m_sName );
assert( pSong );
unsigned int nFramepos;
Hydrogen* pEngine = Hydrogen::get_instance();
AudioOutput* audio_output = pEngine->getAudioOutput();
if ( pEngine->getState() == STATE_PLAYING ) {
nFramepos = audio_output->m_transport.m_nFrames;
} else {
// use this to support realtime events when not playing
nFramepos = pEngine->getRealtimeFrames();
}
Instrument *pInstr = pNote->get_instrument();
if ( !pInstr ) {
ERRORLOG( "NULL instrument" );
return 1;
}
float fLayerGain = 1.0;
float fLayerPitch = 0.0;
// scelgo il sample da usare in base alla velocity
Sample *pSample = NULL;
for ( unsigned nLayer = 0; nLayer < MAX_LAYERS; ++nLayer ) {
InstrumentLayer *pLayer = pInstr->get_layer( nLayer );
if ( pLayer == NULL ) continue;
if ( ( pNote->get_velocity() >= pLayer->get_start_velocity() ) && ( pNote->get_velocity() <= pLayer->get_end_velocity() ) ) {
pSample = pLayer->get_sample();
fLayerGain = pLayer->get_gain();
fLayerPitch = pLayer->get_pitch();
break;
}
}
if ( !pSample ) {
QString dummy = QString( "NULL sample for instrument %1. Note velocity: %2" ).arg( pInstr->get_name() ).arg( pNote->get_velocity() );
WARNINGLOG( dummy );
return 1;
}
if ( pNote->get_sample_position() >= pSample->get_frames() ) {
WARNINGLOG( "sample position out of bounds. The layer has been resized during note play?" );
return 1;
}
int noteStartInFrames = ( int ) ( pNote->get_position() * audio_output->m_transport.m_nTickSize ) + pNote->get_humanize_delay();
int nInitialSilence = 0;
if ( noteStartInFrames > ( int ) nFramepos ) { // scrivo silenzio prima dell'inizio della nota
nInitialSilence = noteStartInFrames - nFramepos;
int nFrames = nBufferSize - nInitialSilence;
if ( nFrames < 0 ) {
int noteStartInFramesNoHumanize = ( int )pNote->get_position() * audio_output->m_transport.m_nTickSize;
if ( noteStartInFramesNoHumanize > ( int )( nFramepos + nBufferSize ) ) {
// this note is not valid. it's in the future...let's skip it....
ERRORLOG( QString( "Note pos in the future?? Current frames: %1, note frame pos: %2" ).arg( nFramepos ).arg(noteStartInFramesNoHumanize ) );
//pNote->dumpInfo();
return 1;
}
// delay note execution
//INFOLOG( "Delaying note execution. noteStartInFrames: " + to_string( noteStartInFrames ) + ", nFramePos: " + to_string( nFramepos ) );
return 0;
}
}
float cost_L = 1.0f;
float cost_R = 1.0f;
float cost_track_L = 1.0f;
float cost_track_R = 1.0f;
if ( pInstr->is_muted() || pSong->__is_muted ) { // is instrument muted?
cost_L = 0.0;
cost_R = 0.0;
if ( Preferences::get_instance()->m_nJackTrackOutputMode == 0 ) {
// Post-Fader
cost_track_L = 0.0;
cost_track_R = 0.0;
}
} else { // Precompute some values...
cost_L = cost_L * pNote->get_velocity(); // note velocity
cost_L = cost_L * pNote->get_pan_l(); // note pan
cost_L = cost_L * fLayerGain; // layer gain
cost_L = cost_L * pInstr->get_pan_l(); // instrument pan
cost_L = cost_L * pInstr->get_gain(); // instrument gain
cost_L = cost_L * pInstr->get_volume(); // instrument volume
if ( Preferences::get_instance()->m_nJackTrackOutputMode == 0 ) {
// Post-Fader
cost_track_L = cost_L * 2;
}
cost_L = cost_L * pSong->get_volume(); // song volume
cost_L = cost_L * 2; // max pan is 0.5
//.........这里部分代码省略.........
示例10: processPlaybackTrack
bool Sampler::processPlaybackTrack(int nBufferSize)
{
Hydrogen* pEngine = Hydrogen::get_instance();
AudioOutput* pAudioOutput = Hydrogen::get_instance()->getAudioOutput();
Song* pSong = pEngine->getSong();
if( !pSong->get_playback_track_enabled()
|| pEngine->getState() != STATE_PLAYING
|| pSong->get_mode() != Song::SONG_MODE)
{
return false;
}
InstrumentComponent *pCompo = __playback_instrument->get_components()->front();
Sample *pSample = pCompo->get_layer(0)->get_sample();
float fVal_L;
float fVal_R;
float *pSample_data_L = pSample->get_data_l();
float *pSample_data_R = pSample->get_data_r();
float fInstrPeak_L = __playback_instrument->get_peak_l(); // this value will be reset to 0 by the mixer..
float fInstrPeak_R = __playback_instrument->get_peak_r(); // this value will be reset to 0 by the mixer..
assert(pSample);
int nAvail_bytes = 0;
int nInitialBufferPos = 0;
if(pSample->get_sample_rate() == pAudioOutput->getSampleRate()){
//No resampling
__playBackSamplePosition = pAudioOutput->m_transport.m_nFrames;
nAvail_bytes = pSample->get_frames() - ( int )__playBackSamplePosition;
if ( nAvail_bytes > nBufferSize ) {
nAvail_bytes = nBufferSize;
}
int nInitialSamplePos = ( int ) __playBackSamplePosition;
int nSamplePos = nInitialSamplePos;
int nTimes = nInitialBufferPos + nAvail_bytes;
if(__playBackSamplePosition > pSample->get_frames()){
//playback track has ended..
return true;
}
for ( int nBufferPos = nInitialBufferPos; nBufferPos < nTimes; ++nBufferPos ) {
fVal_L = pSample_data_L[ nSamplePos ];
fVal_R = pSample_data_R[ nSamplePos ];
fVal_L = fVal_L * 1.0f * pSong->get_playback_track_volume(); //costr
fVal_R = fVal_R * 1.0f * pSong->get_playback_track_volume(); //cost l
//pDrumCompo->set_outs( nBufferPos, fVal_L, fVal_R );
// to main mix
if ( fVal_L > fInstrPeak_L ) {
fInstrPeak_L = fVal_L;
}
if ( fVal_R > fInstrPeak_R ) {
fInstrPeak_R = fVal_R;
}
__main_out_L[nBufferPos] += fVal_L;
__main_out_R[nBufferPos] += fVal_R;
++nSamplePos;
}
} else {
//Perform resampling
double fSamplePos = 0;
int nSampleFrames = pSample->get_frames();
float fStep = 1.0594630943593;
fStep *= ( float )pSample->get_sample_rate() / pAudioOutput->getSampleRate(); // Adjust for audio driver sample rate
if(pAudioOutput->m_transport.m_nFrames == 0){
fSamplePos = 0;
} else {
fSamplePos = ( (pAudioOutput->m_transport.m_nFrames/nBufferSize) * (nBufferSize * fStep));
}
nAvail_bytes = ( int )( ( float )( pSample->get_frames() - fSamplePos ) / fStep );
if ( nAvail_bytes > nBufferSize ) {
nAvail_bytes = nBufferSize;
}
int nTimes = nInitialBufferPos + nAvail_bytes;
for ( int nBufferPos = nInitialBufferPos; nBufferPos < nTimes; ++nBufferPos ) {
int nSamplePos = ( int ) fSamplePos;
double fDiff = fSamplePos - nSamplePos;
if ( ( nSamplePos + 1 ) >= nSampleFrames ) {
//we reach the last audioframe.
//set this last frame to zero do nothin wrong.
//.........这里部分代码省略.........
示例11: __render_note
/// Render a note
/// Return false: the note is not ended
/// Return true: the note is ended
bool Sampler::__render_note( Note* pNote, unsigned nBufferSize, Song* pSong )
{
//infoLog( "[renderNote] instr: " + pNote->getInstrument()->m_sName );
assert( pSong );
unsigned int nFramepos;
Hydrogen* pEngine = Hydrogen::get_instance();
AudioOutput* audio_output = pEngine->getAudioOutput();
if ( pEngine->getState() == STATE_PLAYING ) {
nFramepos = audio_output->m_transport.m_nFrames;
} else {
// use this to support realtime events when not playing
nFramepos = pEngine->getRealtimeFrames();
}
Instrument *pInstr = pNote->get_instrument();
if ( !pInstr ) {
ERRORLOG( "NULL instrument" );
return 1;
}
bool nReturnValues [pInstr->get_components()->size()];
for(int i = 0; i < pInstr->get_components()->size(); i++){
nReturnValues[i] = false;
}
int nReturnValueIndex = 0;
int nAlreadySelectedLayer = -1;
for (std::vector<InstrumentComponent*>::iterator it = pInstr->get_components()->begin() ; it !=pInstr->get_components()->end(); ++it) {
nReturnValues[nReturnValueIndex] = false;
InstrumentComponent *pCompo = *it;
DrumkitComponent* pMainCompo = pEngine->getSong()->get_component( pCompo->get_drumkit_componentID() );
if( pNote->get_specific_compo_id() != -1 && pNote->get_specific_compo_id() != pCompo->get_drumkit_componentID() )
continue;
if( pInstr->is_preview_instrument()
|| pInstr->is_metronome_instrument()){
pMainCompo = pEngine->getSong()->get_components()->front();
} else {
pMainCompo = pEngine->getSong()->get_component( pCompo->get_drumkit_componentID() );
}
assert(pMainCompo);
float fLayerGain = 1.0;
float fLayerPitch = 0.0;
// scelgo il sample da usare in base alla velocity
Sample *pSample = nullptr;
SelectedLayerInfo *pSelectedLayer = pNote->get_layer_selected( pCompo->get_drumkit_componentID() );
if ( !pSelectedLayer ) {
QString dummy = QString( "NULL Layer Information for instrument %1. Component: %2" ).arg( pInstr->get_name() ).arg( pCompo->get_drumkit_componentID() );
WARNINGLOG( dummy );
nReturnValues[nReturnValueIndex] = true;
continue;
}
if( pSelectedLayer->SelectedLayer != -1 ) {
InstrumentLayer *pLayer = pCompo->get_layer( pSelectedLayer->SelectedLayer );
if( pLayer )
{
pSample = pLayer->get_sample();
fLayerGain = pLayer->get_gain();
fLayerPitch = pLayer->get_pitch();
}
}
else {
switch ( pInstr->sample_selection_alg() ) {
case Instrument::VELOCITY:
for ( unsigned nLayer = 0; nLayer < __maxLayers; ++nLayer ) {
InstrumentLayer *pLayer = pCompo->get_layer( nLayer );
if ( pLayer == NULL ) continue;
if ( ( pNote->get_velocity() >= pLayer->get_start_velocity() ) && ( pNote->get_velocity() <= pLayer->get_end_velocity() ) ) {
pSelectedLayer->SelectedLayer = nLayer;
pSample = pLayer->get_sample();
fLayerGain = pLayer->get_gain();
fLayerPitch = pLayer->get_pitch();
break;
}
}
break;
case Instrument::RANDOM:
if( nAlreadySelectedLayer != -1 ) {
InstrumentLayer *pLayer = pCompo->get_layer( nAlreadySelectedLayer );
if ( pLayer != NULL ) {
pSelectedLayer->SelectedLayer = nAlreadySelectedLayer;
pSample = pLayer->get_sample();
//.........这里部分代码省略.........
示例12: on_m_pPlaylistTree_itemDoubleClicked
void PlaylistDialog::on_m_pPlaylistTree_itemDoubleClicked ()
{
QTreeWidgetItem* m_pPlaylistItem = m_pPlaylistTree->currentItem();
if ( m_pPlaylistItem == NULL ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Song selected!" ) );
return;
}
QString selected;
selected = m_pPlaylistItem->text ( 0 );
QTreeWidget* m_pPlaylist = m_pPlaylistTree;
int index = m_pPlaylist->indexOfTopLevelItem ( m_pPlaylistItem );
Playlist::get_instance()->setSelectedSongNr( index );
Playlist::get_instance()->setActiveSongNumber( index );
HydrogenApp *pH2App = HydrogenApp::get_instance();
Hydrogen *pEngine = Hydrogen::get_instance();
if ( pEngine->getState() == STATE_PLAYING ){
pEngine->sequencer_stop();
}
m_pPlayBtn->setPressed(false);
Timeline* pTimeline = pEngine->getTimeline();
pTimeline->m_timelinetagvector.clear();
Song *pSong = Song::load ( selected );
if ( pSong == NULL ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Error loading song." ) );
return;
}
pH2App->setSong ( pSong );
pEngine->setSelectedPatternNumber ( 0 );
HydrogenApp::get_instance()->getSongEditorPanel()->updatePositionRuler();
pH2App->setStatusBarMessage( trUtf8( "Playlist: set song no. %1" ).arg( index +1 ), 5000 );
HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color();
EventQueue::get_instance()->push_event( EVENT_METRONOME, 3 );
///exec script
///this is very very simple and only an experiment
#ifdef WIN32
//I know nothing about windows scripts -wolke-
return;
#else
QString execscript;
selected = m_pPlaylistItem->text ( 1 );
bool execcheckbox = m_pPlaylistItem->checkState ( 2 );
if( execcheckbox == false){
//QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Script selected!" ));
return;
}
if( execscript == "Script not used"){
//QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Script not in use!" ));
return;
}
char *file;
file = new char[ selected.length() + 1 ];
strcpy( file , selected.toAscii() );
int ret = std::system( file );
delete [] file;
return;
#endif
}