DONE! A new Audio-Out Approach in BlitzMax FreeAudio RingBuffer

Started by Midimaster, March 22, 2021, 15:16:23

Previous topic - Next topic

Midimaster

#75
I updated the FreeAudioRingBuffer to version 1.3.2

there was a bug in method Transfer():
Code (BlitzMax) Select
Method Transfer(ShortArray:Short[])
LockMutex BufferMutex
Local WritePointerMod:Int =  WritePointer Mod BUFFER_SIZE
If (ShortArray.Length + WritePointerMod) <= BUFFER_SIZE
For Local i:Int=0 To ShortArray.Length-1
InPtrShort[i+WritePointerMod] = ShortArray[i]
Next
Else
Local Maxi:Int = BUFFER_SIZE-WritePointerMod
For Local i:Int=0 To Maxi-1
InPtrShort[i+WritePointerMod] = ShortArray[i]
Next
For Local i:Int=Maxi To ShortArray.Length-1
'InPtrShort[i]=ShortArray[i+Maxi]   ' <-------  **** HERE ****
InPtrShort[i-Maxi]=ShortArray[i]
Next
EndIf
WritePointer=WritePointer + ShortArray.Length
UnlockMutex BufferMutex
End Method


Quote... Data sent with SendOne() are now processed 10 times as often as before. So now every 100 user Data they are transmitted to the FreeAudio-Driver. This has no hearable effect and is only a test.
The idea of sending very sort chunks in  SendOne() brought no advantages, so I returned to the old code:
Code (BlitzMax) Select
Method SendOne(Value:Int)
' PUBLIC: Use this to...
' send one single sample value to the ringbuffer
'Global ShortArray:Short[100]            <-------  **** HERE ****
Global ShortArray:Short[CHUNK_SIZE]
    Global Counter:Int

Select InFormat
....
End Select
'If Counter = 100                            <-------  **** HERE ****
If Counter = CHUNK_SIZE
CheckBufferOverRun
Transfer ShortArray
          Counter=0
EndIf
End Method




The Updated Source Code
... is here:
https://www.syntaxbomb.com/index.php/topic,8377.msg347049187.html#msg347049187
...back from Egypt