music.play_freq - Kyuchumimo/Micro-Joy-Home-Video-Computer GitHub Wiki

🧩🔊 This is a general-purpose audio-related function.

music.play_freq(channel, freq)

Parameters

  • channel: One of the 3 available channels:0, 1 or 2.
  • freq: Frequency to play. Valid range: 41.203 - 15804.264

Description

Supported frequency range: [41.203 - 15804.264]
Although freqs > 3951.066 shouldn't be used
In terms of musical notes the range is: [E1 - B7+]

This function is used to control the frequency of one of the channels of the AY-3-8910 only.

Note that you can only control the AY-3-8910 and not the Konami SCC. This is because the Konami SCC is intended to be used exclusively for music, while the AY-3-8910 is for sound effects and noise. It is a design choice.

To listen to the tone, remember to use the music.set_vol function first.

When this function is used, it will turn on the tone mixer and turn off the noise mixer of the corresponding channel.

If you are going to use this function for sound effects, remember to update the volume and frequency constantly each frame as needed to avoid conflicts with music playback.
Once finished, you should turn the volume all the way down and play a quiet tone (a frequency that is not audible e.g. music.play_freq(0, 999999)). The music playback will do the rest to recover the audio channel.