Ooops
October 24, 2021, 04:16:42

Author Topic: DONE! A new Audio-Out Approach in BlitzMax FreeAudio RingBuffer  (Read 3904 times)

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 363
    • Midimaster Music Education Software
Found a bug
« Reply #75 on: August 09, 2021, 01:29:56 »
I updated the FreeAudioRingBuffer to version 1.3.2

there was a bug in method Transfer():
Code: BlitzMax
  1. Method Transfer(ShortArray:Short[])
  2.         LockMutex BufferMutex
  3.         Local WritePointerMod:Int =  WritePointer Mod BUFFER_SIZE
  4.         If (ShortArray.Length + WritePointerMod) <= BUFFER_SIZE
  5.                 For Local i:Int=0 To ShortArray.Length-1
  6.                         InPtrShort[i+WritePointerMod] = ShortArray[i]
  7.                 Next                   
  8.         Else
  9.                 Local Maxi:Int = BUFFER_SIZE-WritePointerMod
  10.                 For Local i:Int=0 To Maxi-1
  11.                         InPtrShort[i+WritePointerMod] = ShortArray[i]
  12.                 Next
  13.                 For Local i:Int=Maxi To ShortArray.Length-1
  14.                         'InPtrShort[i]=ShortArray[i+Maxi]   ' <-------  **** HERE ****
  15.                         InPtrShort[i-Maxi]=ShortArray[i]
  16.                 Next
  17.         EndIf
  18.         WritePointer=WritePointer + ShortArray.Length
  19.         UnlockMutex BufferMutex
  20. 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
  1.         Method SendOne(Value:Int)
  2.         ' PUBLIC: Use this to...
  3.                 ' send one single sample value to the ringbuffer
  4.                 'Global ShortArray:Short[100]            <-------  **** HERE ****
  5.                 Global ShortArray:Short[CHUNK_SIZE]
  6.             Global Counter:Int
  7.  
  8.                 Select InFormat
  9.                         ....
  10.                 End Select
  11.                 'If Counter = 100                            <-------  **** HERE ****
  12.                 If Counter = CHUNK_SIZE
  13.                         CheckBufferOverRun
  14.                         Transfer ShortArray
  15.                 Counter=0
  16.                 EndIf
  17.         End Method
  18.  



The Updated Source Code
... is here:
https://www.syntaxbomb.com/index.php/topic,8377.msg347049187.html#msg347049187
« Last Edit: August 09, 2021, 09:33:59 by Midimaster »
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal