Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing #63

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Timing #63

wants to merge 6 commits into from

Conversation

rengels
Copy link

@rengels rengels commented Aug 26, 2023

Fix issues with interrupt timings.

Testing showed that the timer interrupts use each 25us and
have a period (at idle) of 50us.
That means a processor load at more than 100% at idle with pwm inputs.

Turns out the DAC write is using a spin lock for port access which
we don't need.
See https://forum.arduino.cc/t/esp32-dacwrite-ersetzen/653954/5

Now we are down to 10us for the variable and fixed timer interrupts
each.
Resetting the timer frequency takes around 3us.
This is unnecessary for the fixed timer.
We just need to tell the users to keep the same sample
rate for every additional sound (which we kind of already do.)

Else you would have issues anyways, when playing e.g. a horn
and indicator light ticks at the same time.
Three issues are fixed:

1.
in a lot of cases the last sample is not handled.
if (sampleCount < sampleLength-1)
will omit the last sample.

2.
Multiplying the volumes at the end for samples
that are not even outputted makes no sense.
Actually, since all the sounds have a sound volume
it is unnecessary.

3.
Adding the samples directly to a buffer is faster
than first adding it to variables.
I actually used a script for this.
Indicate if you want to have that to automatically
convert.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant