Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output per instruments mixed up #256

Closed
blablack opened this issue May 14, 2015 · 2 comments
Closed

Output per instruments mixed up #256

blablack opened this issue May 14, 2015 · 2 comments
Labels
Milestone

Comments

@blablack
Copy link
Contributor

I have a song with 8 instruments (1 kick, 1 snare, 6 toms) and 3 banks per instruments (Close, Overhead and Room).

For some reason, when i use Output per instruments, some output of the one toms ends up in one of the ouput of the snare.

@blablack
Copy link
Contributor Author

That's one possible way to fix it.

diff --git a/src/core/include/hydrogen/IO/JackOutput.h b/src/core/include/hydrogen/IO/JackOutput.h
index 38d9e39..bdd583f 100644
--- a/src/core/include/hydrogen/IO/JackOutput.h
+++ b/src/core/include/hydrogen/IO/JackOutput.h
@@ -141,7 +141,7 @@ private:
    jack_port_t *           output_port_2;
    QString                 output_port_name_1;
    QString                 output_port_name_2;
-   std::map<string,int>    track_map;
+   int                     track_map[MAX_INSTRUMENTS][MAX_COMPONENTS];
    int                     track_port_count;
    jack_port_t *           track_output_ports_L[MAX_INSTRUMENTS];
    jack_port_t *           track_output_ports_R[MAX_INSTRUMENTS];
diff --git a/src/core/src/IO/jack_output.cpp b/src/core/src/IO/jack_output.cpp
index 57cb3e6..f7e0ae1 100644
--- a/src/core/src/IO/jack_output.cpp
+++ b/src/core/src/IO/jack_output.cpp
@@ -441,25 +441,14 @@ float* JackOutput::getTrackOut_R( unsigned nTrack )

 float* JackOutput::getTrackOut_L( Instrument * instr, InstrumentComponent * pCompo)
 {
-   map<string,int>::iterator it = track_map.find(instr->get_id()+"_"+pCompo->get_drumkit_componentID());
-   if(it != track_map.end())
-       return getTrackOut_L(it->second);
-
-   jack_default_audio_sample_t* out = 0;
-   return out;
+   return getTrackOut_L(track_map[instr->get_id()][pCompo->get_drumkit_componentID()]);
 }

 float* JackOutput::getTrackOut_R( Instrument * instr, InstrumentComponent * pCompo)
 {
-   map<string,int>::iterator it = track_map.find(instr->get_id()+"_"+pCompo->get_drumkit_componentID());
-   if(it != track_map.end())
-       return getTrackOut_R(it->second);
-
-   jack_default_audio_sample_t* out = 0;
-   return out;
+   return getTrackOut_R(track_map[instr->get_id()][pCompo->get_drumkit_componentID()]);
 }

-
 #define CLIENT_FAILURE(msg) {                      \
    ERRORLOG("Could not connect to JACK server (" msg ")"); \
    if (client) {                       \
@@ -653,14 +642,16 @@ void JackOutput::makeTrackOutputs( Song * song )
    WARNINGLOG( QString( "Creating / renaming %1 ports" ).arg( nInstruments ) );

    int p_trackCount = 0;
-   track_map.clear();
+   for( int i = 0 ; i < MAX_INSTRUMENTS ; i++ )
+       for ( int j = 0 ; j < MAX_COMPONENTS ; j++ )
+           track_map[i][j] = 0;

    for ( int n = nInstruments - 1; n >= 0; n-- ) {
        instr = instruments->get( n );
        for (std::vector<InstrumentComponent*>::iterator it = instr->get_components()->begin() ; it != instr->get_components()->end(); ++it) {
            InstrumentComponent* pCompo = *it;
            setTrackOutput( p_trackCount, instr , pCompo, song);
-           track_map[instr->get_id() + "_" + pCompo->get_drumkit_componentID()] = p_trackCount;
+           track_map[instr->get_id()][pCompo->get_drumkit_componentID()] = p_trackCount;
            p_trackCount++;
        }
    }
diff --git a/src/core/src/sampler/sampler.cpp b/src/core/src/sampler/sampler.cpp
index 1a548e6..24f3896 100644
--- a/src/core/src/sampler/sampler.cpp
+++ b/src/core/src/sampler/sampler.cpp
@@ -423,7 +423,6 @@ int Sampler::__render_note_no_resample(
    int nInitialSamplePos = ( int )pNote->get_sample_position(pCompo->get_drumkit_componentID());
    int nSamplePos = nInitialSamplePos;
    int nTimes = nInitialBufferPos + nAvail_bytes;
-   int nInstrument = pSong->get_instrument_list()->index( pNote->get_instrument() );

    float *pSample_data_L = pSample->get_data_l();
    float *pSample_data_R = pSample->get_data_r();
@@ -435,14 +434,6 @@ int Sampler::__render_note_no_resample(
    float fVal_L;
    float fVal_R;

-   /*
-    * nInstrument could be -1 if the instrument is not found in the current drumset.
-    * This happens when someone is using the prelistening function of the soundlibrary.
-    */
-
-   if( nInstrument < 0 ) {
-       nInstrument = 0;
-   }

 #ifdef H2CORE_HAVE_JACK
    JackOutput* pJackOutput = 0;
@@ -585,7 +576,6 @@ int Sampler::__render_note_resample(
    float fInitialSamplePos = pNote->get_sample_position( pCompo->get_drumkit_componentID() );
    double fSamplePos = pNote->get_sample_position( pCompo->get_drumkit_componentID() );
    int nTimes = nInitialBufferPos + nAvail_bytes;
-   int nInstrument = pSong->get_instrument_list()->index( pNote->get_instrument() );

    float *pSample_data_L = pSample->get_data_l();
    float *pSample_data_R = pSample->get_data_r();
@@ -598,15 +588,6 @@ int Sampler::__render_note_resample(
    float fVal_R;
    int nSampleFrames = pSample->get_frames();

-   /*
-    * nInstrument could be -1 if the instrument is not found in the current drumset.
-    * This happens when someone is using the prelistening function of the soundlibrary.
-    */
-
-   if( nInstrument < 0 ) {
-       nInstrument = 0;
-   }
-
 #ifdef H2CORE_HAVE_JACK
    JackOutput* pJackOutput = 0;
    float *     pTrackOutL = 0;

@thijz thijz added the bug label Aug 7, 2015
@thijz thijz added this to the 0.9.7 milestone Aug 7, 2015
@mauser
Copy link
Member

mauser commented Sep 2, 2015

This should be fixed now, thanks @blablack !

@mauser mauser closed this as completed Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants