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

How to play different instruments at the same time using a composition? #90

Open
epbonacina opened this issue Jan 5, 2022 · 4 comments

Comments

@epbonacina
Copy link

epbonacina commented Jan 5, 2022

I've been trying to play different tracks using different instruments, but all tracks play the same instrument.
When I execute the example below, the only thing I can hear is the Acoustic Grand Piano playing both tracks.

    instrument = MidiInstrument("Acoustic Grand Piano")
    instrument2 = MidiInstrument("Oboe")
  
    track_container = Track(instrument)
    track_container_2 = Track(instrument2)
    track_container.add_notes(['C-6', 'E-6', 'G-6', 'B-6'])
    track_container_2.add_notes(['E-6', 'G#-6', 'B-6', 'D-6'])

    composition = Composition()
    composition.add_track(track_container)
    composition.add_track(track_container_2)

    fluidsynth.play_Composition(composition, bpm=60)

If I switch the composition.add_track methods, as in the example below, the Oboe becomes the only audible instrument.


    instrument = MidiInstrument("Acoustic Grand Piano")
    instrument2 = MidiInstrument("Oboe")

    track_container = Track(instrument)
    track_container_2 = Track(instrument2)
    track_container.add_notes(['C-6', 'E-6', 'G-6', 'B-6'])
    track_container_2.add_notes(['E-6', 'G#-6', 'B-6', 'D-6'])

    composition = Composition()
    composition.add_track(track_container_2)
    composition.add_track(track_container)

    fluidsynth.play_Composition(composition, bpm=60)

If I pass the channels parameter to the fluidsynth.play_Composition method, nothing changes.

What is wrong with my codes? A composition should be able to play multiple instruments, right?

@epbonacina
Copy link
Author

I made another example, using only tracks.

    track_container = Track()
    track_container_2 = Track()

    track_container.add_notes(['C-6', 'E-6', 'G-6', 'B-6'])
    track_container_2.add_notes(['E-6', 'G#-6', 'B-6', 'D-6'])
    
    fluidsynth.set_instrument(1,127)
    fluidsynth.play_Track(track_container, 1)
    fluidsynth.play_Track(track_container_2, 2)

I set the gunshot sound to play on channel 1, but both channels are playing this sound. What am I doing wrong?

@cwurld
Copy link

cwurld commented Feb 26, 2022

Hi. This is a bug. Essentially, all output goes to channel 1 and a channel only allows one instrument. It's fixed in my fork (https://github.com/cwurld/python-mingus).

In fact I am making some major changes. I am not maintaining python 2 compatibility. I have changed how the sequencer works. I am working on percussion. Also there is some code structure that seems odd to me.

While I very much appreciate all the work others have done on this project, I am not sure they will even want my contributions merged. So my fork might turn into a separate project. We will see. python-mingus-big-band?

Chuck

@epbonacina
Copy link
Author

epbonacina commented Mar 8, 2022

Thanks, Chuck.
I'm using your fork now, and things seem to be working.
I hope they merge your contributions.

@b8d241b26a27cbcf2c7345393

Thanks @cwurld ! I spent hours trying to find the cause in the sequencer without success. Long life to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants