Giter Club home page Giter Club logo

Comments (17)

melanchall avatar melanchall commented on June 19, 2024

If you use release version of the library, there is no way to do this. But you can take develop sources and then you can use EventCallback and NoteCallback properties of the Playback class to set callbacks to filter out those events and notes with muted channels.

playback.NoteCallback = (d, rt, rl, t) => mutedChannels.Contains(d.Channel) ? null : d;

playback.EventCallback = (e, rt, t) =>
{
    var channelEvent = e as ChannelEvent;
    if (channelEvent == null)
        return e;

    return mutedChannels.Contains(channelEvent.Channel) ? null : e;
};

You can set these callbacks before playback start and they will be automatically applied to all events and notes during playback.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Hello melanchall,

Thanks really a lot for your fast response to my 3 issues!!
And thanks really a lot for your great work and the possibility to use „DryWetMidi“!!

With best regards
Thomas

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

Thomas,

You are welcome! :) Thanks for using the library. Please close issues if they are resolved.

Max

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Thanks a lot, Max.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

I have one additional comment or proposal:
I locally changed the source of "Playback.cs" and added a new property with an Array of bool - for every midi channel ("channelEnabled[16]") to mute or Play.

In "TryPlayNoteEvent " I changed a small part of Code:

        if (midiEvent != null)
        {
            // TF: Realize "Mute"
            if (midiEvent is NoteOnEvent)
            {
                int channel = ((NoteOnEvent)midiEvent).Channel;

                if (channelEnabled[channel])
                    SendEvent(midiEvent);
            }
            else
                SendEvent(midiEvent);

That's simpler and faster than using events.....

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Mixer
This is the current status of the mixer with mute and solo-buttons...

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

Hi Thomas,

Hmm, it seems reasonable to implement this feature. I'll do it :)

Your implementation slightly incomplete since there are other channel events except NoteOn. You should check if an event is an instance of ChannelEvent.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Hi Max,
Important is, that the mute/solo can be used while the midi-file is playing.
If you are now muting a channel - and the note-off will not be send anymore - you have not the expected behaviour... :-)
(Another situation: a program change event is not sent, and the channel is switched on again....)

Because of that I think Note_On seems to be ok for muting....

Regards
Thomas

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Hi Max,
I never worked in a Github-Repository....
Would you generally accept proposals for changes from others than you?
I copied the Developer-Repository to my machine - and did locally changes.
How can you see my proposal - and accept or reject?

Greetings
Thomas

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

Hi Thomas,

Recently I've merged PR from @zivillian (#36). So yes, I accept changes from users :)
To create PR you need to fork my repo, push your changes to your fork and create PR from your branch to the develop branch of my repo.

But array of bools is not good. Index should be of type FourBitNumber and the check for out of range should exist. I think it would be better to create methods like MuteChannel/UnmuteChannel/IsChannelMuted with all required checks and proper arguments types.

Please do PR and we'll discuss it :)

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

PR was created - issue can be closed… :-)

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

I reopen the issue. Please clarify your requirement according to your last comment on #45.

Do you in fact mute channels on TrackChunk instead of Playback? What does it mean? There is no concept of muting on track chunk level since MIDI spec hasn't such thing.

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

As I mentioned in the PR: It‘s fine and sufficient for me to have the mute functionality on the level of midi Channels.
What I‘m currently implementing is a midi- editor inclusive midi-Sequenzer functionality. The base of all sequencers is typically a track - you call it track-chunk. So if the sequencer plays all tracks - and these can be more than 16, even the Midi-Standard supports only 16 Channels(Devices) - it would be a good thing to be able to mute these tracks.... A typical example can be the drum-tracks, for which all drum parts can be splittet - the base-drum on a track, the HiHat on a separate track etc. Nevertheless all tracks are using midi-channel 10... It would be helpful to mute the base-drum, but to mute the drums on channel 10 is currently sufficient for me...

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

OK, I've got it. Interesting case. I'll think how it can be implemented.

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

Well, I've investigated efforts needed for this task and it seems new class Sequencer should be implemented. But I'm going to create such class in one of new versions of the library in the future. At now I recommend to use approach suggested in my first reply.

Thanks for using the library and for sharing your experience!

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

Ooh - that means my simple solution for the Midi-Channels will not be integrated and also not your method-call solution ?

from drywetmidi.

melanchall avatar melanchall commented on June 19, 2024

It's just unncecessary since there is a way to achieve what you want (and it's not so complex as you think). You just need to manage array of bools on your side. Also you can easily replace all array at once and callbacks will use new array automatically.

Also inside callback you can check what track note or event belongs to and mute/unmute it. So you can arrange your data into logical tracks, not by channels.

from drywetmidi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.