BT and pitch bend

56 views
Skip to first unread message

Andrew Nolan

unread,
Sep 4, 2023, 12:55:01 AM9/4/23
to WVR Audio
any thoughts to implementing BT for audio out on the ESP32?
Also, I would like to implement pitchbend  - I use the arduino MIDI.h library. 

WVR Audio

unread,
Sep 4, 2023, 1:21:13 AM9/4/23
to WVR Audio
Bluetooth output: It seems that Espressif has recently published some examples on how to do this. That wasn't the case last time I looked. There are now some tutorials available on how, and an Arduino library which offers it. The problem is of course to enumerate all the available BT receivers in range, list them in the UI, and then allow the user to choose one. This is a little awkward but not so bad really. I am not sure if I will have time soon, but I will add it to the todo list. I would also love to see someone try to experiment with this library, and see if it is possible to combine with WVR firmware. I have a Bluetooth midi firmware, which works well, but, it uses the very small Bluetooth library for ESP32 called NimBLE. This library is small enough that it could fit along side all the WVR code. I am not sure if it would be easy to use that library to work with those linked above, and if the resulting binary would be too big to fit on WVR.

Pitchbend is something that has been on the todo list for quite a while. It is a real challenge. When you say you would like to implement it, do you mean you want to write some code to accomplish it? The WVR uses a very large portion of its processor power to accomplish 18 voices of polyphony. Adding DSP of any kind has led very quickly to losing voices. However I have only tried using floating point math for these operations, it is very likely that using fixed point DSP math could yield better results, but I am a self taught programmer, and fixed point math is a little outside my skills currently. I have had a plan to level up in this way, but have not found time yet. Is that something you have the experience to contribute?

Andrew Nolan

unread,
Sep 4, 2023, 2:15:42 AM9/4/23
to WVR Audio
I am mainly interested in BT for audio out to wireless earphones, as you say there would need to be a way to pick devices in ranges in the UI. This would best be the via webapp for selection and turning on. 
Concerning pitchbend -it is a feature of the acoustic flute I am emulating, using both breath pressure and altering mouth position independently - its up to a semitone pitch. I have so far got to a basic instrument which responds to breath velocity using expression and can jump octaves without resorting to octave keys  Because this device only uses one voice, I dont need polyphony. I am a self taught programmer myself. I will have a look at the code to find potential spots where the pitch altering could be implemented. 

WVR Audio

unread,
Sep 4, 2023, 12:13:15 PM9/4/23
to WVR Audio
If you don't need polyphony, it's possible you could achieve it using floating points.
the general formula is  y_i = (1-a)x + ax_z
This will achieve linear interpolation, which should sound good enough.

David Battino

unread,
Sep 5, 2023, 1:14:03 AM9/5/23
to WVR Audio
Good to see pitchbend come up again! That's probably #1 on my wishlist, though I'm hoping for a two semitone range. (Even better would be two up and 12 down for special effects. I remember you said the quality declines as the range increases, but sometimes bitcrusher effects are useful. ;-)

WVR Audio

unread,
Sep 11, 2023, 12:17:12 AM9/11/23
to WVR Audio
I am on vacation for a few weeks and tinkering on pitch bend in my spare time, it's coming along well, but I wont be able to test it until I am home.
I am using fixed point math, and optimistic that we will not lose any voices.
There is a branch on github if anyone is curious to follow along: https://github.com/marchingband/wvr/tree/pitch-bend

WVR Audio

unread,
Sep 23, 2023, 6:25:53 PM9/23/23
to WVR Audio
I'm very happy to report that pitchbend for +2 semitones and -1 octave are all working great, with no loss of polyphony voices 🚀
I only have it implemented for one-shot playback so far, but the new fixed-point math is looking very promising!

David Battino

unread,
Sep 23, 2023, 9:58:06 PM9/23/23
to WVR Audio
Great! If I wanted to try it, would I have to compile a binary file somehow from the files in the pitch bend directory?

WVR Audio

unread,
Sep 24, 2023, 1:47:59 AM9/24/23
to WVR Audio
one-shot works well, loop works ok, but still clicks a little (I think).

WVR Audio

unread,
Sep 24, 2023, 3:00:53 AM9/24/23
to WVR Audio
in the WEB UI, in the WVR tab, there is pitch-bend up, and pitch-bend down settings you must pick (they default to 0)

WVR Audio

unread,
Sep 24, 2023, 3:25:11 PM9/24/23
to WVR Audio
Ok one-shot, loop, and ASR are all working ok now.
ASR needs a little work with glitches on pitch-up sometimes.
I have updated the beta binary linked above

David Battino

unread,
Sep 24, 2023, 3:26:30 PM9/24/23
to WVR Audio
Thanks! I'll try to check it out tonight. This feature should make a big difference.

WVR Audio

unread,
Sep 24, 2023, 3:48:17 PM9/24/23
to WVR Audio
With ASR loop were at about 15 voices of polyphony. I may be able to refactor it to get the last 3 back, but it is getting very complex :-/

David Battino

unread,
Sep 25, 2023, 3:59:05 PM9/25/23
to WVR Audio
Pitch-bend is fantastic! Thanks again. I did notice a bug: When I bend up, it overrides the note-off parameter. So looping sounds never stop and one-shots play to the end instead of halting.

WVR Audio

unread,
Sep 25, 2023, 6:50:44 PM9/25/23
to WVR Audio
Oh wow that was a naaaasty bug ... classic forgotten break in a switch/case statement ... causing the release times to get corrupted.
thank you!

Yes if I listen very hard I THINK I can hear a little aliasing? Much better quality then I expected.

WVR Audio

unread,
Sep 25, 2023, 8:05:40 PM9/25/23
to WVR Audio
Ok I have got ASR refactored to work better and fixed your bug.
We have 18 voices again in ASR mode, but there is still glitching when we pitch-up all 18.
I will continue to look for more ways to refactor for efficiency, but this may be the outcome.
I am not sure how to handle this situation, where if in ASR mode, we must limit the polyphony according to the pitch-up amount, or else face the possibility that users will get glitches if they push it.
Perhaps the default pitch-up is 0, and there is a warning when it is changed, that polyphony will be reduced to x voices?

WVR Audio

unread,
Sep 25, 2023, 8:36:07 PM9/25/23
to WVR Audio
A little more refactoring and I think we have 18 voices on all modes with +2 semitones / -12 semitones pitch bend!
I have updated the binary to wvr_pitch_bend_beta_rc.bin for the release candidate 🍾
Please give it a test and let me know any bugs or clicks or weirdness you encounter.
Thanks!

Andrew Nolan

unread,
Sep 26, 2023, 1:02:27 AM9/26/23
to WVR Audio
Thanks, for my wind instrument the pitch bend will occur 1) as a slight increase in pitch tied to the the air stream velocity (max 0.2 ST)and 2) the same tied to a proximity sensor at the embouchure -I have yet to work out which sensor - maybe IR measuring closure of embouchure hole the or even and ultrasonic distance sensor. I think it means that 1) the embouchure sensor would have to self calibrate on first breath and 2) pitchbend CC would have to be sent each loop along with expression CC. Which brings me to the next point, how fast can the WVR respond to these CC messages?  Say I am feeding them to the WVR from a loop running at say 100 Hz.

WVR Audio

unread,
Sep 26, 2023, 1:39:59 AM9/26/23
to WVR Audio
I don't know of any limit on accepting messages, if we hit one I can always increase the buffer sizes, however it updates the volumes/pan/other CCs/pitch-bend/etc only once per buffer of 256 samples so around 150hz.

WVR Audio

unread,
Sep 26, 2023, 1:44:11 AM9/26/23
to WVR Audio

I wonder if cap sense would work on the embouchure, if designed, combined and programmed correctly they can respond in fancy ways. Some of the cap sense keyboards you see give the sense that they detect pressure, and certainly respond to position. You could need to coat the sensors not use raw wires like you mentioned. https://ww1.microchip.com/downloads/en/Appnotes/Capacitive-Touch-Sensor-Design-Guide-DS00002934-B.pdf

Andrew Nolan

unread,
Sep 26, 2023, 2:04:12 AM9/26/23
to WVR Audio
yes I think so. I plan to make my finger contacts covered with a thin layer of plastic film, and sitting at the bottom of a shallow hole 6mm wide x 0.5mm deep to give the feel of a wooden natural flute. The proximity touch type sensor could sit at the bottom of the embouchure well and would respond to coverage by the lower lip.
Reply all
Reply to author
Forward
0 new messages