示例#1
0
 void InstrumentEditor::rubberbandbpmchangeEvent()
{
	 if( !Preferences::get_instance()->getRubberBandBatchMode() /*&& Preferences::get_instance()->__usetimeline */){
		 //we return also if time-line is activated. this wont work.
		 //		INFOLOG( "Tempo change: Recomputing rubberband samples is disabled" );
		 return;
	 }
//	INFOLOG( "Tempo change: Recomputing rubberband samples." );
	Hydrogen *pEngine = Hydrogen::get_instance();
	Song *song = pEngine->getSong();
	assert(song);
	if(song){
		InstrumentList *songInstrList = song->get_instrument_list();
		assert(songInstrList);
		for ( unsigned nInstr = 0; nInstr < songInstrList->size(); ++nInstr ) {
			Instrument *pInstr = songInstrList->get( nInstr );
			assert( pInstr );
			if ( pInstr ){
				for ( int nLayer = 0; nLayer < MAX_LAYERS; nLayer++ ) {
					InstrumentLayer *pLayer = pInstr->get_layer( nLayer );
					if ( pLayer ) {
						Sample *pSample = pLayer->get_sample();
						if ( pSample ) {
							if( pSample->get_rubberband().use ) {
								//INFOLOG( QString("Instrument %1 Layer %2" ).arg(nInstr).arg(nLayer));
								Sample *newSample = Sample::load(
											pSample->get_filepath(),
											pSample->get_loops(),
											pSample->get_rubberband(),
											*pSample->get_velocity_envelope(),
											*pSample->get_pan_envelope()
											);
								if( !newSample  ){
									continue;
								}	
								delete pSample;
								// insert new sample from newInstrument
								AudioEngine::get_instance()->lock( RIGHT_HERE );
								pLayer->set_sample( newSample );
								AudioEngine::get_instance()->unlock();
	
							}
						}
					}
				}
			}
		}
	}

}
示例#2
0
/// Preview, uses only the first layer
void Sampler::preview_sample( Sample* sample, int length )
{
	AudioEngine::get_instance()->lock( RIGHT_HERE );

	InstrumentLayer *pLayer = __preview_instrument->get_layer( 0 );

	Sample *pOldSample = pLayer->get_sample();
	pLayer->set_sample( sample );

	Note *previewNote = new Note( __preview_instrument, 0, 1.0, 0.5, 0.5, length, 0 );

	stop_playing_notes( __preview_instrument );
	note_on( previewNote );
	delete pOldSample;

	AudioEngine::get_instance()->unlock();
}
示例#3
0
/// Preview, uses only the first layer
void Sampler::preview_sample( Sample* sample, int length )
{
	AudioEngine::get_instance()->lock( RIGHT_HERE );

	for (std::vector<InstrumentComponent*>::iterator it = __preview_instrument->get_components()->begin() ; it != __preview_instrument->get_components()->end(); ++it) {
		InstrumentComponent* pComponent = *it;
		InstrumentLayer *pLayer = pComponent->get_layer( 0 );

		pLayer->set_sample( sample );

		Note *pPreviewNote = new Note( __preview_instrument, 0, 1.0, 0.5, 0.5, length, 0 );

		stop_playing_notes( __preview_instrument );
		note_on( pPreviewNote );

	}

	AudioEngine::get_instance()->unlock();
}