Accurate usage of the Thumby.Audio.Play function

CoolieCoolster

  • Full Member
  • ***
    • Posts: 30
    • View Profile
As I wanted my game, NanoMem, to make use of the Thumby's audio capabilities, when finalizing the function that illuminates the pattern outputs I assigned each output a frequency value that matched forth-octave notes. Unsure what the optimal volume would be, I had left the third field of the function blank so that it would default to the preset of 50%. After asking someone who had received a pre-release unit to test NanoMem for functionality, as they said the audio was very quiet I modified the audio output functions with the values of the third field set to the maximum value defined in the API. When they tried the modified version, however, there was no audio at all; is there another factor I may have missed?


Jason

  • Administrator
  • Hero Member
  • *****
    • Posts: 106
  • TinyCircuits Employee
    • View Profile
Hi,

It makes sense that you wouldn't hear anything at 100% duty cycle, that's a constant voltage at that point.

Take a look at the plot on this website for an example: https://resources.pcb.cadence.com/blog/2020-pulse-width-modulation-characteristics-and-the-effects-of-frequency-and-duty-cycle

If the duty cycle is 100%, then the voltage in the linked plot would be 5V always, therefore no sound. Also, looking at that plot, the duty cycle does not correlate to volume. During any period, when the signal is HI it is at its max.

If you look at some of our games, like TinyBlocks, you should be able to find examples of using the API that work well: https://github.com/TinyCircuits/tinycircuits.github.io/blob/master/ThumbyGames/Games/TinyBlocks/TinyBlocks.py#L292

Keep in mind that the speaker on the Thumby is also pretty quiet, there really isn't a way to make the sound louder.
« Last Edit: November 09, 2021, 01:38:14 PM by Jason »


 

SMF spam blocked by CleanTalk