That looks great thanks for sharing!
Is that a HC-SR04 you are using as a distance sensor?
The buttons look good and smooth (despite the fact that one of them was not working, alas!), do you have a link to the product page?
Do you get to use the built-in speaker? Is that a passive speaker powered by Bela?

Just one minor correction on your pass-through latency figure;
assuming you are using analog input to audio out, you have:

  • ~1 ADC sample conversion delay
  • ~1 samples transmission (SPI) delay
  • 32 samples due to the dual buffering (16 samples per buffer)
  • ~1 transmission (McASP) delay
  • 21 samples DAC converter filter group delay

That adds up to ~66 samples, that is - at 44.1kHz - 1.5ms.
If you use the audio in, then you get 17 samples group delay in the ADC, so that makes for a total of 82 samples. so 1.9ms!

    giuliomoro

    Currently the distance sensor is aSHARP distance sensor IR GP2Y0A21YK0F. I have linearised its output with a least squares fit, it works ok, but I'm still not 100% satisfied with the performance. I'm currently investigating better options... Will try this out next: Adafruit VL53L0X Time of Flight Distance Sensor - ~30 to 1000mm

    Other suggestions? You think HC-SR04 is a good choice ?

    Theres is no product page as such...

    Best,
    Hjalte

    I am not exactly an expert in this field. I worked with IR sensors but for much shorter distances. I am a bit concerned that for stage use an IR sensor may be less reliable, due to ambient light (have you tried it outside on a sunny day?) and sudden changes (e.g.: strobe stage lights), and also dirt on the sensor. Probably this sensor includes some way of rejecting the effect of ambient light, but I'd want to test it extensively before relying on it for a stage performance.
    The laser option - in comparison - seems better, but I have never used one.

    I have used one HC-SR04 once and in the comparison with something that looked a bit like GP2Y0A21YK0F, it had a much wider sensing angle (15degrees I believe) , which may or may not be desirable for your application. This example code for the HC-SR04 should get you started easily if you want to try one out. The resolution of the reading is limited by the sampling rate, so when using digital out and digital in, it should give you a theoretical resolution down to 3.9mm.

      giuliomoro Hmm, you might have a good point about the lighting conditions. I think the sharp sensor uses modulated IR light as source and filters in incoming which provides some noise rejection - but sunlight is probably problematic.

      Laser light can also easily be confused by direct sunlight ...

      I think the indoor stage environment will not be problematic in both cases, but this would have to be tested 😉

      I have some HC-SR04 lying around, so I'll try it out and let you know how it performs....

      Thank you for the input !