The WAV Trigger Gets Expressive

wheels

The MIDI mod wheel already controls sustain. Now pitch bending has come to the WAV Trigger! I spend the weekend implementing real-time sample-rate conversion and got it hooked up to MIDI Pitch Bend messages. At the moment, this means that a MIDI controller pitch wheel can control the playback pitch/speed of the WAV Trigger by plus or minus a fixed number of semi-tones. A firmware update with this new feature is forthcoming, after I sort out a few details of how to control this new effect.

A little background…

In the days of hardware samplers and limited/expensive memory, sample-rate conversion was used to spread a single sample over a number of MIDI keys, thereby saving memory. This meant that each voice had to have it’s own sample-rate conversion engine. With many gigabytes now available on microSD cards, this is no longer necessary, since you can afford to have an individual sample for every note on the keyboard. (I admit that this is time-consuming to set up, but you only have to do so once.) Pitch bend, on the other hand, usually affects all notes equally.

The new sample-rate conversion in the WAV Trigger occurs in the final output stage rather than on each individual voice. At the moment, all voices are affected equally, allowing you to bend chords like the pitch control on a Mellotron. I’m considering a 2-channel approach, whereby one channel will be fixed and the other processed through the sample-rate conversion engine, and tracks can be designated to play through one or the other channel. (Both channels are then mixed to the stereo output.) This would allow you to, for example, have a stereo backing track at a fixed sample rate while playing instrument samples with pitch bend along with it.

It makes sense for the MIDI pitch wheel to allow pitching up or down by a value corresponding to a whole musical interval, usually some number of semi-tones. I plan to also add control through the serial protocol, but allow setting the rate to any arbitrary value between say 0.5x and 2.0x. I’ve been thinking it would be fun to try to build a digital Theremin using an Arduino to sense hand positions and send serial volume and  pitch control messages to the WAV Trigger playing a sine wave sample. That should work, right?

Would love to hear thoughts on this.

 

Jamie

  • reply Dan Lavin ,

    I’m guessing the intent of the 2-channel mixing would be for chorus/flanging effects? Or would that be beyond your project scope at this point? Personally, I’d be happy with simply pitch bending. I’m working on a set of guitar power chords for the Wav trigger. It’d be nice to have an octave of power chords with a couple octaves of single notes that can be bent.

    • reply jamie@robertsonics.com ,

      The purpose of the 2-channel mixing would simply to allow for pitch bending on some tracks but not others. For example, if you wanted to play along with a stereo backing track, you’d want to be able to pitch bend the instrument sound you’re playing without affecting the backing track. It just provides a way to decide whether a particular sound is affected by the sample-rate conversion or not.

      Chorus and flanging are algorithms that require RAM. The only RAM the WAV Trigger has is what’s in the STM32F4, and most of that is being used to optimize getting data off the microSD card fast enough to support 14 stereo voices. I intend to look into this at some point, but it’s likely that there isn’t enough memory to support both 14 voices and delay-based effects.

      Pitch bending works now, I just need to finish up the control options. Let me know if you want to try it before I get to the next release.

      • reply Dan Lavin ,

        Jamie: thanks for the explanation…makes perfect sense. I’m still experimenting making wav files that are WT compatible, so I think I can wait a bit on pitch bend. By the way, I just did the mellotron gong from the same page source as the other samples. I assigned it to note 036 so it can sit on a low C of a 4 octave keyboard along the usual mellotron sample set w/o interference. Is there a place to collect WT compatible samples yet?

    • reply Kevin Grannum ,

      Hi Jamie, I’m using the wav trigger both in the MIDI world as a module and as a sound fx device remotely controlled by the operator using serial comms. As the FX device it is being used in part to simulate motor noise. So at present I have x number of samples which loop for x number of motor speeds. The issue then becomes a smooth transition between the motor speed samples. Currently I’m looking at crossfading but if you can introduce pitch bend maybe then a portamento option may blend the samples together better. Not sure how this could work given the motor noises are noise and not assigned to keys. But yeah a Theremin using noise rather than a sine wave would be perfect for me. Cheers

      • reply jamie@robertsonics.com ,

        My thinking is that the only difference between MIDI pitch bend and serial sample-rate control would be the limits. With MIDI pitch bend you usually want the stops to be some number of musical semitones. With serial control, I will probably allow you to go from half speed to double speed with 16-bit resolution. This will certainly allow you to smoothly pitch engine sounds up or down. The only issue is how far can you pitch bend an engine sample before it starts sound weird or not like an engine.

      • reply Baloran ,

        Bravo, what great idea and what a great achievement ! Integrated in a few minutes in my sequencer, and immediately a nice surprise when the sound quality. I have The Small Sound Box that I missed.

        Thank you ; )

        • reply jamie@robertsonics.com ,

          Thank you for the kind words. Keep an eye out on the download page – I’ll have an update with pitch bend coming soon.

          And please spread the word.

        • reply Ethan ,

          OMG!! Pitch Bend would be awesome!! Jamie, I got this thing set up as a Mellotron / Optigan using an old cruddy sears organ but with nice FATAR keybed I salvaged from an old Baldwin. I really cannot believe how incredible this sounds! I designed a daughter board that contains a PIC based MIDI decoder, Switching PSU and Class D amp. MIDI latency is not perceptible whatsoever. I have to admit that as awesome as the Mellotron sounds, the Optigan is a lot more fun. but you really need speed/pitchbend with that. I was going to use audacity to change speed and/pitch, and save files to different channels. That would take a lot of work! I’ll post a video ASAP. You are my hero!

          • reply jamie@robertsonics.com ,

            Flattery will get you everywhere.

            Seriously, if all you want is MIDI Pitch Bend, I could give you that now. All I would need is for you to tell me the number of semitones up and down you want the range to be. But it sounds like maybe you’re using the PIC to receive MIDI and the WAV Trigger serial protocol to control the audio? If so, I need to finish the serial commands for controlling pitch/speed – maybe by this weekend. Or is the PIC doing the key detection and sending MIDI to the WAV Trigger?

            If you’re willing, a video would be tremendous. I don’t think a lot of people get quite what this is yet. And thanks for the kind words.

            • reply Ethan ,

              • reply jamie@robertsonics.com ,

                This is AWESOME! Really nice work. If it’s ok with you, I’d like to tweet a link to this, which will no doubt be retweeted by SparkFun and will likely be seen by 50K+ followers.

                At some point, I’d love to see a photo or two of the electronics.

                Thanks, -Jamie

                • Ethan ,

                  Sure, no problem. I’ll get a photo of electronics also.

          • reply Dan Lavin ,

            Hello again Jamie. Just letting you know I’ve had a lot of fun creating sound banks for the Wav Trigger. Unfortunately, most of the web sites say you’re free to use the samples but ask you don’t share them, so I think the idea of a repository of sound banks may be difficult to do. Audacity has been very helpful in pitching shifting sample sets of instruments that aren’t sampled completely chromatic. Quite a few samples I’ve found are just the “white notes.”
            If I could make 1 suggestion for a firmware upgrade it would be to disable the midi channel sound bank selection. There’s a few of us that still do old school hardware midi sequencing and it’s difficult to do with the current set-up. Otherwise, the software with the upcoming pitch bend, is perfect for my needs. At some point, would it be possible to use midi velocity to switch between sound banks? For instance, I could play normal guitar notes below a velocity of 100 and have harmonics sounds sounds above that point. I wouldn’t want to over-complicate this thing, just thought it would be fun to do.

            • reply Ethan ,

              Hi Jamie, What are pro’s and cons of controlling the wav trigger using the serial protocol vs. MIDI? For example would using the UART at 57.6kbps yield better latency or increased performance overall compare to standard MIDI at 31.25kbps. The reason I am asking is I am having a tough time implementing pitch bend. My MIDI controller is based off a PIC project which doesn’t have pitch bend. I can’t seem to find any projects online that involve pitch bend controller and I don’t want to buy a MIDI keyboard w.pitch bend.. So I have decided to start coding my own using Atmel. Since my C skills are weak this is going to take a long time.

              • reply jamie@robertsonics.com ,

                The only difference is baud rate and command set. The latency isn’t going to change between the two protocols. If you are using the WAV Trigger as a musical instrument, then MIDI is probably the way to go. If you need fancy stuff like crossfading tracks, then you’ll need to use the serial control protocol.

                Musical pitch bending, such as bending up and down a whole number of semi-tones will be much easier using the MIDI Pitch Bend message, since the bend range is already calculated for you – it’s just a 14-bit value with the mid-point being nominal pitch. If you use the samplerate offset command in the serial protocol, you’ll have to calculate the offset to be musical.

                Hope this helps.

              • reply Ethan ,

                Hey Jamie. Almost got MIDI pitch bend working. Sanity check… the pitch change can occur real time, corect? Currently, pitch bend is working but only after a note is played on the keyboard. In other words, I have a pot connected to ATMEGA 328, being used as an A/D. The A/D is bit manipulated to adhere to MIDI Pitch bend spec. I play a note and adjus the pot. The pitch only changes when I play the note again. I think it is my code but I just want to make sure before get it in too deep.

                • reply jamie@robertsonics.com ,

                  Pitch bend is real-time and affects the output of all the voices, even while they’re playing. If I remember correctly, this is demonstrated by the example sketch in the WAV Trigger Arduino serial library. From your description, it does sound like it could be a issue with your code.

                  • reply Ethan ,

                    Hi Jamie,
                    It’s been a while since I played around with my Pitch bend code. I got it working but there is some slight glitches. I know it’s my code because pitch bend works great with an Alesis MIDI Keyboard with pitch wheel. My question is can you or anybody point me somewhere to help me properly code pitch bend in C? Maybe look at some examples. Google searches are only giving me limited results. The arduino libraries don’t seem to help too much because there is too much stuff going on under the hood. I am using ATMEL328p in Atmel Studio 7. Thanks to anybody who helps.

                    • reply jamie@robertsonics.com ,

                      Are you doing pitch bend using MIDI or the serial protocol? If the latter, you can look at the example code in the WAV Trigger Serial Library to see how it’s done. If you’re using MIDI Pitch Bend messages, you just need to remember that you have to split the 14-bit pitch value into 2 7-bit data bytes, and that the value goes from 0 to 16,383, with 8192 being center (not pitched up or down.)

                      Hope this helps

                • reply Sam ,

                  I have two “Wav Trigger’s” with midi inputs connected in parallel.
                  On the first “Wav Trigger” I have loaded melody notes. These notes I wish to have pitch bend on for playing vibrato.
                  The second “Wav Trigger” has a selection of continuously played drone notes (selected midi notes not being used by the melody), playing a chord (to sound a bit like a bagpipe).
                  These notes I do not wont any pitch bend on.

                  The question is:
                  Is there a way to disable the pitch bend on the second “Wav Trigger”, to achieve this set-up?

                  Leave a comment