So i have a Project where i basically wanna stream Binary Audio Files via PyAudio in Memory instead of converting it to a .wav File or similiar
Now my Main Issue is the Playback of the File as i just get out nothing output and i am unsure as to what exactly is wrong?
I based my Decoder on this C# Code: https://raw.githubusercontent.com/VitorVilela7/SMW-CodeLib/refs/heads/master/cs/music/BRR.cs
and play the File back via this Code
import pyaudio
import numpy as np
def play_pcm(pcm_data, sample_rate=32000):
audio = pyaudio.PyAudio()
stream = audio.open(format=pyaudio.paInt16,
channels=1,
rate=sample_rate,
output=True)
pcm_bytes = np.array(pcm_data, dtype=np.int16).tobytes() # Convert PCM data to bytes
stream.write(pcm_bytes) # Stream the PCM data
stream.stop_stream()
stream.close()
audio.terminate()
def play_brr_sample(brr_file):
with open(brr_file, 'rb') as file:
brr_data = file.read()
pcm_data = decode_brr(brr_data)
play_pcm(pcm_data)
def main():
play_brr_sample("EPiano.brr")
if __name__ == "__main__":
main()
Here is also the SNES BRR Document: https://snes.nesdev.org/wiki/BRR_samples
also i am still somewhat new to Python but Binary Files are still very confusing to me
Sound samples played by the S-SMP DSP are stored in the BRR (bit-rate-reduction) data format.
BRR is composed of 16-sample blocks, each of which is stored in 9 bytes of data. This is a 1 byte control block, followed by 8 bytes containing 16 4-bit samples to be decoded (high nibble first).
When a block with the end (E) flag set finishes, the cha...