Playing Chords in Metasounds, not just single Nodes?

Hey, I´ve got my System set up to accept MIDI Inputs from my LAUNCHKEY MK3

It sends one note to my MetaSound System (with Velocity and one trigger for the Envelope)
Logically, if I press 3 Keys at once for a chord, it only plays the most recent key. Makes sense. Is there a tutorial on how I can change that and send Chords?
My guess is filling up a buffer and sending the buffer (in form of string etc. etc.) to Metasounds.
SoundFXGuy on YouTube solves it in having a trigger for each and every note which seems to be a bit excessive.

Is there another way?

You definitely don’t need a trigger for each and every note, but you will need a way to explicitly allow polyphony. I.e., you’ll need to decide the maximum amount of notes you’re okay with having playing at once, and then have that many sound sources.

There are a few ways to go about handling polyphony, but honestly the easiest one is probably to use multiple audio components, with the same MetaSound. When you make multiple instances of the same MetaSound, they don’t share parameters. So like, if you have two Audio Components each playing your MetaSound at ‘C’, and you switch the pitch of one of them to ‘A’, then you will hear both a note at ‘A’ and one at ‘C’. If you’re tracking Note Off in addition to Note On messages, it can get a little messy finding which note you want to turn off, but its definitely doable.

If you’re really determined to only have one Audio Component, you could also change the MetaSound to take an array of pitches and an array of velocities, respectively. You’d still need to have multiple voices within your MetaSound to play all of them, though.

Hey Anna!
Thanks for your swift reply!
I don´t know why I didn´t think about using multiple Audio Components… that seems to be such a no-brainer…
I have worked on a System that… sort of works. I tried the Array approach, however this proved to be very difficult to control. I couldn´t quite figure out when to flush the array…

So I worked out a “ticketing system”

  1. Checks if the pressed key is already in the Array. If yes, that means the incoming note is most likely to be the “Note-Off” signal and we set that Position to 0.

  2. If “No”, then check the array for the first available spot that has a value of “0” (no note) and

  3. route it to one correct “set float parameter” according to the array index of that value. (Max of 5 notes right now for testing purposes)

The Metasound Page looks like this:

Right now, I do get a lot of… well the notes don´t sound right. Not even when Single notes are played so… I sense some sort of destructive interference. It sounds very distorted.
Any GLARING issues on the first look that you could sense? Do the notes need to be multiplied in MS as opposed the mixed? It´s my first time dealing with Metasound… probably shouldn´t straight away jump into coding Synths haha

Mixing the notes should work fine, but if the sum of the waves is over 1.0, you’ll start getting clipping, which sounds like sending a guitar amp into overdrive. The pic’s a little blurry, but it looks like each wave is currently set to a gain of 0.9, which, if they’re all playing at once, is pretty likely to get clamped. Try 0.2.

(I’m admittedly not sure what you’re trying to do with the Mono Mixer (2) at the end, there, though. That’ll just double your volume, and there are easier ways to do that. You should be able to just send the product of the note sum and the AD envelope directly to Out Mono.)

Oh, I see. It totally makes sense. For whatever reason I thought that the Mixer would just take care of that stuff. (Kind of like setting Spotify and YouTube to 90% volume won’t blow your eardrums out, on the pc.) But if it’s additive… Then that’s probably the reason why it sounds like it does.

Thank you very much for taking your time!

Well, the Mixer does take care of that stuff! It just takes care of it by making everything > 1.0, equal to 1.0. It won’t blow your speakers, but it will change the waveform.

(Minor correction: the clamping happens at the output of the MetaSound, not during the Mixer. But ya, the Mixer doesn’t do anything fancy like normalize stuff, it pretty much just adds things together. Mostly cause sometimes people clip stuff on purpose. It’s pretty common behavior in DAWs as well, fwiw: What Is Audio Clipping? How to Fix It in Your DAW)

I’m trying to have multiple instances of a Metasound (each with a different frequency(float) value as input), playing simultaniously to generate a chord. I can play individual notes just fine, but when I try and play more than one note together the sound becomes very distorted. Is there any way around this?

Yes! This is almost certainly the exact same problem the above person was talking about - you can fix this by making sure the total gain is less than 1.0. You can use Mixer Nodes or Multiply Audio by Float Nodes to accomplish this.

(Some context, if its helpful: generator nodes have an output of [-1.0, 1.0] if they’re bipolar, and [0.0, 1.0] when they’re unipolar. When you play multiple sounds at the same time, what happens is their outputs are added together - so for example, two bipolar sine can hit an output value of 2.0 when both waves are at their peak, which can happen at the same time regardless of if they have different frequencies or not.

MetaSounds deals with volume control through a hard-clamp, i.e., any signal that’s sent to it that’s higher than 1.0 will just be set to 1.0 before it hits your headphones. Same for output less than -1.0. This prevents dangerous volume hikes, but it changes the shape of your waveform - you would no longer be playing a sine wave, you’d be playing a wave with a much flatter top, which has an auditory effect that’s often described as distorted. I put an article above with a bunch more technical information about this phenomenon if you want it.

So what you do to fix it is get your output range back into [-1.0, 1.0]. The fast way to do this is to divide by the amount of notes you’ll play at once. E.g., if you have 2 sine waves, multiply the output of both by 0.5. If you have 3, multiply the output by 0.333. And so on. )

The solution of @lanztz.anna_1 has solved my issue and should solve yours. I just send my audio into space just for it to be hard limited. Tuning down the Gains on the Mixer-Node solved this and now it works flawlessly <3