1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

A question about audio through the selector module

Discussion in 'Building With Reaktor' started by djimbe, Mar 20, 2017.

  1. djimbe

    djimbe Forum Member

    Messages:
    47
    I last year (almost a year ago!) was getting some basic help on this forum in regards to a voice-stealing system I was making for Ableton Live using Reaktor -

    (This was the thread, but it's not necessary to read. Just here for interest/continuity:
    https://www.native-instruments.com/...oftsynths-in-logic-pro-x.269440/#post-1467446)

    - I finished several versions of it and am now trying it out in composition for the first time.

    The ensemble uses a selector module to switch between 4 incoming audio sources based on incoming (doctored) midi events, and is only ever passing 1 of the audio sources through.

    What I notice is that the output is pretty clicky around the voice changes. My guess is that this is because there's no guarantee the source switch will occur during zero crossings. Switching to the linear or sine crossfade options on the module makes no difference - I assume because the selection switch is also instantaneous. I mean, the module never sees any values other than the 4 specific channel ids I'm using of 0, 1, 2 and 3.

    What I'm after is a microscopic crossfade on every voice change. My question is - what do you think it the best way to approach or program this? Or can it be handled more automatically by me using something other than the selector?

    I've attached the audio mixing portion of the system, which is where the selecting occurs.
    (It could probably be less hectic to the eyes. I couldn't get it working with a table, and by the time I'd worked out what was wrong - which I forget what it was, because that was a year ago -- I had already made a 'hardcoded' version of it without a table which WAS working ; ) )

    Thanks much for any help.
     

    Attached Files:

  2. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    Place a smoother right before the selector control input, adjust the smoother value to your liking, try this first as it's the simplest solution
     
  3. colB

    colB NI Product Owner

    Messages:
    3,969
    switching during zero crossings won't necessarily fix the problem, and it is not practical anyway...
    Crossfade is probably the way to go. Or you could try a fade out followed by fade in.
    For crossfade, you need the two audio streams (fading from and fading to) to both be playing until the fade is complete, so just toggling between them with an instantaneous selector switch 'aint going to work. fade out followed by fade in allows you to still use the instantaneous switch, but you need to process the sequence: fade out; switch; fade in.
     
  4. colB

    colB NI Product Owner

    Messages:
    3,969
    Here's a relatively simple approach using an array. It's probably not optimal in terms of cpu efficiency, but shouldn't be an issue unless you try and scale up the approach dramatically, or use lots and lots of simultaneous instances of it.
    fade selector.PNG

    The idea is to write all four incoming streams to the four entry array, but only read the two required for the cross fade. The 1..0 ramp is triggered by a new channel input, and its output is used to generate the fade.
    This could be developed further so that the audio clock is routed only to the components that need it in order to save cpu.

    I've uploaded the example, but without the 4 sequenced synths, to reduce the file size. In the example, there is a panel switch to choose channel, and a knob to select fade time in milliseconds.
     

    Attached Files:

  5. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    I would eliminate the switch and replace it with a selector, switches cause initialization events that can lead to pops and clicks
     
  6. colB

    colB NI Product Owner

    Messages:
    3,969
    The switch was just there because it's a quick sketchy demo - the useful bit is the crossfade selector code. Hey, and you should always endeavour to build your ensembles so they gracefully deal with switch resets ;)

    But wth, here's a version with a bespoke radio switch set built from buttons! EDIT: meh, its kinda broken... the only way to do radios is with mouse areas or displays... bleagh
     

    Attached Files:

    Last edited: Mar 21, 2017
    • Like Like x 2
  7. djimbe

    djimbe Forum Member

    Messages:
    47
    Thanks for the replies so far everyone. I'm going to try things out and report back.
     
  8. djimbe

    djimbe Forum Member

    Messages:
    47
    Hm, thanks colB. Your crossfade selector was a pretty good start. I hooked up my channel selector logic to your ensemble and started to get the effect. I still get pops and clicks here and there, but they're not at random. They occur at predictable points in a track. I think what might be happening is that in the moment when my ensemble recalculates which channel should grab the mic next, maybe there's a click when it races through more than one option quickly, like at moments when one of the four voices drops out entirely. I'd have to reinvestigate its logic.
     
  9. djimbe

    djimbe Forum Member

    Messages:
    47
    As an update on the clicks, I added a clock that prevents the currently selected voice # from being forwarded to the selector any faster than once a millisecond. That eliminated all clicking, so I think the clicks were something to do with the logic of my voice changer.
     
  10. colB

    colB NI Product Owner

    Messages:
    3,969
    The example I posted requires you to leave at least the fade time before making another change, otherwise the new and old indices are changed and the fade restarted before the previous fade is complete.

    Some options are:
    Force the system doing the switching to always wait long enough - which is what you are doing
    Or
    Build an event buffer so that if a new switch event arrives before a fade is complete, store it until the fade is complete, then apply it. This approach is more general and more flexible, but also more complex to implement. It requires a simple state machine.
    OR
    An even more complex fading system that can handle fading out multiple channels from their current amitude as the most recent input channel is faded in from its existing amplitude. This could work pretty well in general. Every channel would have a fade module and these would be triggered to fade up or fade down depending on the value of the most recent control index.
     
  11. colB

    colB NI Product Owner

    Messages:
    3,969
    Here's a version that handles each channel separately, using state machines to manage fading and minimise the overhead from inactive channels. Functionality is probably very similar to arachnaut's Quietswitch.
     

    Attached Files:

    • Like Like x 1
  12. djimbe

    djimbe Forum Member

    Messages:
    47
    Thanks again arachnaut and colB! I'm still pondering the ramifications of the first one I tried (colB) but keen to try all these.

    One thing occurred to me, though. Why is this (relatively) so hard when monophonic synths basically operate this way out of the box? I mean, when you hold down a key on a mono synth, then press the one beside it, and the second one takes over (with no crossfade from the first note, and no fade in to the second), what mechanism do they employ that ends note 1 and starts note 2 'immediately' with no fade/click? Is it just a tiny release stage and then it starts note 2?
     
  13. colB

    colB NI Product Owner

    Messages:
    3,969
    Monophonic synths don't operate this way out of the box!

    They use an envelope to control the amplitude. In most monosynths when a new note is started, the envelope begins it's attack at the existing amplitude value from the previous note, it doesn't reset to zero every time (that would cause a click). They often have a limit on the fastest attack/decay times, because if these are too fast, the clicks start to sound like bugs/glitches.
     
  14. djimbe

    djimbe Forum Member

    Messages:
    47
    OK that's right, I forgot about the simplest case : )

    But then how about something like a drum machine, or drum machine synth, on a mode with one voice and automatic voice cancellation?
     
  15. djimbe

    djimbe Forum Member

    Messages:
    47
    Thanks Col. This one works very well out of the box. I was able to remove my event speed limiter and there are no clicks anywhere (unless you set the fade time to so microscopic that you'd expect them)