AlexOfOz Active Member Licensed User Longtime User Nov 19, 2022 #1 Many, many, many years ago, the Commodore 64 allowed me to generate sound using peeks and pokes. Is there an equivalent option to generate sounds using B4* ?? Thanks, Alex
Many, many, many years ago, the Commodore 64 allowed me to generate sound using peeks and pokes. Is there an equivalent option to generate sounds using B4* ?? Thanks, Alex
E emexes Expert Licensed User Longtime User Nov 19, 2022 #2 Make yourself a PCM sample and feed it to the speaker. The SID chip's square, saw and triangle waveforms are easy enough to generate; the white noise is a little harder. Upvote 0
Make yourself a PCM sample and feed it to the speaker. The SID chip's square, saw and triangle waveforms are easy enough to generate; the white noise is a little harder.
E emexes Expert Licensed User Longtime User Nov 19, 2022 #3 Whilst I was off finding sample audio output code, I stumbled across this nice diagram of the SID: Upvote 0
E emexes Expert Licensed User Longtime User Nov 19, 2022 #4 The code in this post shows both recording from microphone to PCM samples, and playing back the recorded PCM samples: https://www.b4x.com/android/forum/threads/noise-detector-by-microphone.143377/#post-909162 eg: B4X: Copy Private Sub Play_Click btnStartRec.Enabled = False streamer.StartPlaying For Each b() As Byte In buffers streamer.Write(b) Next streamer.Write(Null) 'when this "message" will be processed, the player will stop. End Sub where the b() byte arrays are simply 16-bit samples in... I think little-endian format, but I'll go double-check that. This post suggests little-endian: https://www.b4x.com/android/forum/threads/noise-detector-by-microphone.143377/#post-909176 and that you can use ByteConverter to transform between Array of Shorts (easier for you to work with) and Array of Bytes (that the audio streamer is expecting): B4X: Copy Dim bc As ByteConverter bc.LittleEndian = True Dim Sample16() As Short = bc.ShortsFromBytes(Buffer) Upvote 0
The code in this post shows both recording from microphone to PCM samples, and playing back the recorded PCM samples: https://www.b4x.com/android/forum/threads/noise-detector-by-microphone.143377/#post-909162 eg: B4X: Copy Private Sub Play_Click btnStartRec.Enabled = False streamer.StartPlaying For Each b() As Byte In buffers streamer.Write(b) Next streamer.Write(Null) 'when this "message" will be processed, the player will stop. End Sub where the b() byte arrays are simply 16-bit samples in... I think little-endian format, but I'll go double-check that. This post suggests little-endian: https://www.b4x.com/android/forum/threads/noise-detector-by-microphone.143377/#post-909176 and that you can use ByteConverter to transform between Array of Shorts (easier for you to work with) and Array of Bytes (that the audio streamer is expecting): B4X: Copy Dim bc As ByteConverter bc.LittleEndian = True Dim Sample16() As Short = bc.ShortsFromBytes(Buffer)