Comments (17)
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.
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.
Thomas,
You are welcome! :) Thanks for using the library. Please close issues if they are resolved.
Max
from drywetmidi.
Thanks a lot, Max.
from drywetmidi.
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.
This is the current status of the mixer with mute and solo-buttons...
from drywetmidi.
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.
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.
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.
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 bool
s 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.
PR was created - issue can be closed… :-)
from drywetmidi.
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.
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.
OK, I've got it. Interesting case. I'll think how it can be implemented.
from drywetmidi.
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.
Ooh - that means my simple solution for the Midi-Channels will not be integrated and also not your method-call solution ?
from drywetmidi.
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)
- Anytime I retrieve a device from InputDevice.GetByIndex() it returns a new instance of that device. HOT 4
- Failing to Dispose() of an InputDevice results in never being able to use that device again. Until Unity restart. HOT 3
- Connection issues and how to debug them? HOT 5
- Can't sync midi file notes with audio file HOT 12
- HELP !!! Notes in panel to midi file?? HOT 9
- please help a noob HOT 6
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
- InputDevice event listening crash HOT 2
- Crash when running in Unity on M2 MacBook HOT 3
- MidiDeviceException Internal error HOT 9
- Android Support
- Unity cannot exit after use HOT 10
- MidiClock sync problem HOT 6
- MIDI Tempo changes count returns 1 but the song has 6 tempo changes. HOT 1
- add il2cpp mode HOT 5
- CustomChunk no mididata throw error HOT 4
- CSharp Code Error HOT 2
- MIDI File returns error: InvalidMetaEventParameterValueException HOT 1
- Unable to send Note-On event to device HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drywetmidi.