craigthomas / Chip8Java

A Super Chip 8 emulator written in Java
MIT License
27 stars 2 forks source link

Add Audio Playback Operation #30

Open craigthomas opened 2 months ago

craigthomas commented 2 months ago

The XO Chip specification states that a new 16-byte pattern buffer should be generated to hold digital samples for playback. This internal buffer is set using the audio operation with opcode F002. The function reads 16 bytes starting from memory address pointed to by the index register into the 16-byte internal pattern buffer. When the sound timer is non-zero, the 16-byte pattern buffer is played back at a frequency that depends on the pitch register. The playback frequency of the sample is determined by the following equation:

4000 * 2^((pitch - 64) / 48)

The audio pattern is played at the specified frequency (in Hz) until the sound timer reaches (or is set to) 0. The pattern remains in the internal pattern buffer until a subsequent audio operation replaces the pattern in the buffer. The pattern buffer is initialized to be all zeros.