pi1541 / Pi1541

Commodore 1541 emulator for the Raspberry Pi
GNU General Public License v3.0
369 stars 80 forks source link

Piezo buzzer noise reduction for V1.24 on PI0 #213

Open r107sl opened 3 years ago

r107sl commented 3 years ago

If the PI0 GPIO pin controlling the buzzer (PIGPIO_OUT_SOUND) is high without playing drive head sequence, the buzzer is emitting annoying noise coming from the 5V supply voltage. In case of PIGPIO_OUT_SOUND low the buzzer is quiet. Please make sure to set the pin always low after a head noise sequence is finished. Tested modification of main.cpp:

    if (options.SoundOnGPIO() && headSoundCounter > 0)
    {
        headSoundFreqCounter--;     // Continue updating a GPIO non DMA sound.
        if (headSoundFreqCounter <= 0)
        {
            headSoundFreqCounter = headSoundFreq;
            headSoundCounter -= headSoundFreq * 8;
            if (headSoundCounter <=0 and IEC_Bus::OutputSound == false) {headSoundCounter += headSoundFreq * 8;}            
            IEC_Bus::OutputSound = !IEC_Bus::OutputSound;
        }
    }

In addition the settings in options.txt aren't behaving like described. SoundOnGPIOFreq value results only in half the frequency. SoundOnGPIODuration is definitely not micro seconds, but I couldn't reverse engineer the effect.