How HiFi mode works?

421 views
Skip to first unread message

Ben Holmes

unread,
Apr 2, 2014, 5:39:00 AM4/2/14
to mozzi...@googlegroups.com
Long time Arduino synth maker (not with huge success), short term Mozzi user here. I've been reading around the github.io for Mozzi trying to find answers for how HiFi works, but I can't seem to find any definitive answers. So far I've found:

HiFi "Doesn’t need a notch filter on the audio signal because the carrier frequency is out of hearing range (STANDARD_PLUS also doesn’t need it)". This makes me think that the sample rate is pushed to 32 kHz for the system. But at the same time "updateAudio() is where audio synthesis code should be placed. This runs on average 16384 times per second, so code here needs to be lean." This seems to imply that the sample rate is always at 16 kHz, even if the carrier frequency of the PWM is doubled.

Does this mean that when running in Standard+ and HiFi that the audio buffer repeats a sample to double the carrier frequency but maintain the sample rate? Or is there something that I've missed entirely?

Tim Barrass

unread,
Apr 3, 2014, 7:02:52 AM4/3/14
to mozzi...@googlegroups.com
Hi Ben,
thanks, yes the docs could certainly do with some improving and it helps to get feedback.

The sample rate stays at 16384 Hz unless you deliberately set AUDIO_RATE to 32768 Hz in mozzi_config.h.  The PWM carrier frequency is 16384 Hz for STANDARD mode, 32768 Hz in STANDARD_PLUS, and 125kHz in HIFI mode.
The sample rate/audio output buffer rate doesn't change with the different PWM carrier frequencies, as the PWM wave plays whatever it has most recently been set to by the audio output routine - there's no need to explicitly repeat a sample. 

One additional confusing element is that the new STANDARD_PLUS mode achieves the increased PWM frequency rather clumsily by exiting from each alternate ISR without doing anything, since the ISR and PWM are both on the same timer and hence run at the same frequency.  HIFI avoids this wasted processor time by using a different timer for the audio output interrupt, seperate from the PWM timer.  These parts of the Mozzi code are currently under active revision, in which some problems are being solved, and other inefficiencies are being introduced!

If you're really curious, there's a line in the ISR for STANDARD and STANDARD_PLUS modes where the output register gets set (AUDIO_CHANNEL_1_OUTPUT_REGISTER is #defined as OCR1A in AudioConfigStandard9bitPwm.h and AudioConfigStandardPlus.h)

    AUDIO_CHANNEL_1_OUTPUT_REGISTER = output_buffer[(unsigned char)output_buffer_tail & (unsigned char)(BUFFER_NUM_CELLS-1)];

The timer chapters in the downloadable Atmel manual "8-bit Microcontroller with 4/8/16/32K Bytes In-System Programmable Flash" have more info if you're interested (and who wouldn't be?!).

Tim


--
You received this message because you are subscribed to the Google Groups "Mozzi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozzi-users...@googlegroups.com.
To post to this group, send email to mozzi...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mozzi-users/4faa9b4b-2351-478e-9901-8ff01fd4e51d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages