B4A Library AudioTrack

Roger Taylor

Member
Licensed User
Longtime User

I don't have an issue with logging messages from a thread. The issue is that at.WriteByte isn't writing the samples. At least there is silence when the command is executed from within the thread type I mentioned.

As for sleep() being used in a thread, try to run a thread having a forever loop such as "Do While (True=True), Loop" and put some commands in the loop and the compiler will complain that some or any of them are "unreachable". Sleep(0) allows my thread to stay in the loop. I have another looping thread (the 6809 CPU emulation) that loops without requiring a sleep command, but doesn't crash if I insert a sleep just as a test.

The following method for a loop works, but the sound is highly distorted.... perhaps because the writes are too soon... I'll investigate.
Sub DacThread

Dim i = 0 As Int
Do While (i = (i-i))
at.WriteByte(CycleBy, 0, 1)
Loop

End Sub
 
Last edited:

Roger Taylor

Member
Licensed User
Longtime User

kimstudio

Active Member
Licensed User
Longtime User
It should be stream_music and mode_stream in Initialize. How the samplerate and samplebits set? If the samplerate you want to emulate can't reach the samplerate supported in at.Initialize, upsampling is needed.
 

stevel05

Expert
Licensed User
Longtime User
Try to post a simple example project where it fails, that would help us to help you. And you might find the problem while you do it.
 

Roger Taylor

Member
Licensed User
Longtime User
It should be stream_music and mode_stream in Initialize. How the samplerate and samplebits set? If the samplerate you want to emulate can't reach the samplerate supported in at.Initialize, upsampling is needed.

Try to post a simple example project where it fails, that would help us to help you. And you might find the problem while you do it.

I'm basically trying to do what this C64 emulator is doing. I need to insert live DAC samples into the AudioTrack stream, as my retro CPU is writing them at it's own rate to it's own DAC... whatever the last sample was should keep getting inserted into the AudioTrack stream to satisfy the requires that AudioTrack expects a new byte in an array per the sample rate. So think of what I'm doing as a live DAC output, which I'm shocked that Android doesn't just support easily.

 

Roger Taylor

Member
Licensed User
Longtime User
Cookies are required to use this site. You must accept them to continue using the site. Learn more…