hello,

this patch will fix:

insert new instrument --> jack track-output will refreshed
remove instrument --> jack track-output will refreshed
metronome nInstrument = 0 -> hydrogen out_L & out_R in use
preview  in libary nInstrument = 0 -> hydrogen out_L & out_R in use
there is a little bug if you disconnect out_L and out_R in jack ... so
dont disconnect out_L and out_R and it's work perfect.

PatternEditorInstrumentList.cpp
void InstrumentLine::functionRandomizeVelocity()
now work.

Greetings Wolke 
-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free
diff -Naur hydrogen/gui/src/PatternEditor/PatternEditorInstrumentList.cpp hydrogen/gui/src/PatternEditor/PatternEditorInstrumentList.cpp
--- hydrogen/gui/src/PatternEditor/PatternEditorInstrumentList.cpp	2008-03-25 12:58:40.000000000 +0100
+++ hydrogen/gui/src/PatternEditor/PatternEditorInstrumentList.cpp	2008-03-25 14:04:33.000000000 +0100
@@ -296,46 +296,62 @@
 
 void InstrumentLine::functionRandomizeVelocity()
 {
-	ERRORLOG( "[functionRandomizeVelocity] not implemented yet" );
-/*
-	Hydrogen *engine = Hydrogen::get_instance();
-	engine->lockEngine("PatternEditorInstrumentList::functionRandomizeVelocity");
-
-	int nSelectedInstrument = engine->getSelectedInstrumentNumber();
-
-	int nPattern = engine->getSelectedPatternNumber();
-	Pattern *pPattern = engine->getSong()->getPatternList()->get( nPattern );
-
-	Sequence *pSequence = pPattern->m_pSequenceList->get( nSelectedInstrument );
-	for ( int i = 0; i < pPattern->m_nSize; i++ ){
-		Note *pNote = pSequence->m_noteList[ i ];
-		if ( pNote ) {
-			float fVal = ( rand() % 100 ) / 100.0;
-			fVal = pNote->m_fVelocity + ( ( fVal - 0.50 ) / 2 );
-			if ( fVal < 0  ) {
-				fVal = 0;
-			}
-			if ( fVal > 1 ) {
-				fVal = 1;
-			}
-			pNote->m_fVelocity = fVal;
-		}
+	Hydrogen *pEngine = Hydrogen::get_instance();
+
+	PatternEditorPanel *pPatternEditorPanel = HydrogenApp::getInstance()->getPatternEditorPanel();
+	DrumPatternEditor *pPatternEditor = pPatternEditorPanel->getDrumPatternEditor();
+
+	AudioEngine::get_instance()->lock("PatternEditorInstrumentList::functionRandomizeVelocity");	// lock the audio engine
+
+	int nBase;
+	if ( pPatternEditor->isUsingTriplets() ) {
+		nBase = 3;
+	}
+	else {
+		nBase = 4;
 	}
-	engine->unlockEngine();
+	int nResolution = 4 * MAX_NOTES / ( nBase * pPatternEditor->getResolution() );
 
-	engine->getSong()->__is_modified = true;
+	Song *pSong = pEngine->getSong();
 
-//	m_pPatternEditorPanel->getPatternEditor()->updateEditor(true);
-//	m_pPatternEditorPanel->getVelocityEditor()->updateEditor();
-//	m_pPatternEditorPanel->getPitchEditor()->updateEditor();
+	Pattern* pCurrentPattern = getCurrentPattern();
+	if (pCurrentPattern != NULL) {
+		int nPatternSize = pCurrentPattern->get_lenght();
+		int nSelectedInstrument = pEngine->getSelectedInstrumentNumber();
+
+		if (nSelectedInstrument != -1) {
+			Instrument *instrRef = (pSong->get_instrument_list())->get( nSelectedInstrument );
+
+			for (int i = 0; i < nPatternSize; i += nResolution) {
+				std::multimap <int, Note*>::iterator pos;
+				for ( pos = pCurrentPattern->note_map.lower_bound(i); pos != pCurrentPattern->note_map.upper_bound( i ); ++pos ) {
+					Note *pNote = pos->second;
+					if ( pNote->get_instrument() == instrRef ) {
+						float fVal = ( rand() % 100 ) / 100.0;
+						fVal = pNote->get_velocity() + ( ( fVal - 0.50 ) / 2 );
+						if ( fVal < 0  ) {
+							fVal = 0;
+						}
+						if ( fVal > 1 ) {
+							fVal = 1;
+						}
+						pNote->set_velocity(fVal);
+					}
+				}
+			}
+		}
+	}
+	AudioEngine::get_instance()->unlock();	// unlock the audio engine
 
 	// this will force an update...
-	EventQueue::getInstance()->pushEvent( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
-*/
+	EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
+
 }
 
 
 
+
+
 void InstrumentLine::functionDeleteInstrument()
 {
 	Hydrogen *pEngine = Hydrogen::get_instance();
@@ -372,6 +388,9 @@
 	AudioEngine::get_instance()->get_sampler()->stop_playing_notes();
 
 	delete pInstr;
+	#ifdef JACK_SUPPORT
+	pEngine->renameJackPorts();
+	#endif
 	AudioEngine::get_instance()->unlock();
 
 	// this will force an update...
@@ -434,6 +453,12 @@
 InstrumentLine* PatternEditorInstrumentList::createInstrumentLine()
 {
 	InstrumentLine *pLine = new InstrumentLine(this);
+		#ifdef JACK_SUPPORT
+		AudioEngine::get_instance()->lock( "PatternEditorInstrumentList::newInstrument" );
+		Hydrogen::get_instance()->renameJackPorts();
+		AudioEngine::get_instance()->unlock();
+		#endif
+
 	return pLine;
 }
 
@@ -486,9 +511,6 @@
 
 		}
 	}
-
-
-
 }
 
 
@@ -584,6 +606,9 @@
 
 		AudioEngine::get_instance()->lock( "PatternEditorInstrumentList::dropEvent" );
 		pEngine->getSong()->get_instrument_list()->add( pNewInstrument );
+		#ifdef JACK_SUPPORT
+		pEngine->renameJackPorts();
+		#endif
 		AudioEngine::get_instance()->unlock();
 
 		// select the new instrument
diff -Naur hydrogen/libs/hydrogen/include/hydrogen/hydrogen.h hydrogen/libs/hydrogen/include/hydrogen/hydrogen.h
--- hydrogen/libs/hydrogen/include/hydrogen/hydrogen.h	2008-03-25 12:58:42.000000000 +0100
+++ hydrogen/libs/hydrogen/include/hydrogen/hydrogen.h	2008-03-25 13:23:03.000000000 +0100
@@ -142,6 +142,7 @@
 
 	int getSelectedInstrumentNumber();
 	void setSelectedInstrumentNumber( int nInstrument );
+	void renameJackPorts();
 
 private:
 	static Hydrogen* instance;
diff -Naur hydrogen/libs/hydrogen/src/hydrogen.cpp hydrogen/libs/hydrogen/src/hydrogen.cpp
--- hydrogen/libs/hydrogen/src/hydrogen.cpp	2008-03-25 12:58:45.000000000 +0100
+++ hydrogen/libs/hydrogen/src/hydrogen.cpp	2008-03-25 13:23:03.000000000 +0100
@@ -2339,5 +2339,13 @@
 	EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );
 }
 
+
+#ifdef JACK_SUPPORT
+void Hydrogen::renameJackPorts()
+{
+	audioEngine_renameJackPorts();
+}
+#endif
+
 };
 
diff -Naur hydrogen/libs/hydrogen/src/sampler/sampler.cpp hydrogen/libs/hydrogen/src/sampler/sampler.cpp
--- hydrogen/libs/hydrogen/src/sampler/sampler.cpp	2008-03-25 12:58:44.000000000 +0100
+++ hydrogen/libs/hydrogen/src/sampler/sampler.cpp	2008-03-25 13:23:03.000000000 +0100
@@ -350,6 +350,8 @@
 		if ( __audio_output->has_track_outs() ) {
 			// hack hack hack: cast to JackOutput
 #ifdef JACK_SUPPORT
+			if (nInstrument < 0 )
+				nInstrument = 0; 
 			float* track_out_L = ( ( JackOutput* )__audio_output )->getTrackOut_L( nInstrument );
 			float* track_out_R = ( ( JackOutput* )__audio_output )->getTrackOut_L( nInstrument );
 			assert( track_out_L );
@@ -503,6 +505,8 @@
 		if ( __audio_output->has_track_outs() ) {
 #ifdef JACK_SUPPORT
 			// hack hack hack: cast to JackOutput
+			if (nInstrument < 0 )
+				nInstrument = 0; 
 			float* track_out_L = ( ( JackOutput* )__audio_output )->getTrackOut_L( nInstrument );
 			float* track_out_R = ( ( JackOutput* )__audio_output )->getTrackOut_L( nInstrument );
 			assert( track_out_L );
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to