1
0
mirror of https://github.com/sjlongland/atinysynth.git synced 2025-09-13 18:13:16 +10:00

attiny861 port: Fix annoying pop on each note.

It seems when the NJM2113 is first powered up, it emits a pop noise.
Not much I can do about that.  The thought was I should power down the
amplifier when it is not in use to save power.

The outcome is on each note, it would power the amp up, and it would
pop.

Solution: create a 1msec timer for general timing events, and use that
to count down one minute before powering off the amplifier.  The toy
will pop on first power on, then if left alone for a minute, will pop
again on the first note, but will not pop so long as there's only short
gaps between notes.
This commit is contained in:
Stuart Longland 2017-06-11 16:09:42 +10:00
parent 1cc66ace92
commit aeefd70fe3
Signed by: stuartl
GPG Key ID: F954BBBB7948D546

View File

@ -47,14 +47,17 @@ struct voice_ch_t poly_voice[VOICES];
/*! Synthesizer state */
struct poly_synth_t synth;
/*! Amplifier turn-off delay */
static volatile uint8_t amp_powerdown = 0;
/*! 1-millisecond timer tick */
static volatile uint16_t ms_timer = 0;
/*! Amplifier turn-off delay in seconds */
static volatile uint16_t amp_powerdown = 0;
/*!
* Delay in powering down amplifier, since it makes an annoying pop when
* it does power down. (Sample ticks)
*/
#define AMP_POWERDOWN_DELAY (100)
#define AMP_POWERDOWN_DELAY (60000)
/*! Number of I/O channels */
#define CHANNELS (8)
@ -205,8 +208,22 @@ int main(void) {
button_hit = 0;
button_release = 0;
/* Turn on amp early */
PORTB |= AUDIO_EN;
amp_powerdown = AMP_POWERDOWN_DELAY;
/* Enter main loop */
while(1) {
/* Count down millisecond timer */
if (!ms_timer) {
/* One millisecond has passed */
ms_timer = SYNTH_FREQ/10;
/* Tick down the amplifier power-down timer */
if ((!synth.enable) && amp_powerdown)
amp_powerdown--;
}
/* Check the button states */
uint8_t b = 0;
uint8_t bm = 1;
@ -297,9 +314,9 @@ ISR(TIMER0_COMPA_vect) {
DDRA = 0x00;
}
/* Tick down the amplifier power-down timer */
if ((!synth.enable) && amp_powerdown)
amp_powerdown--;
/* Tick down the one-second timer */
if (ms_timer)
ms_timer--;
/* Compute and output the next sample */
int8_t s = poly_synth_next(&synth);