I finally Finshed My Specdrum Clone

Started by wadmixfm, June 03, 2021, 18:14:35

Previous topic - Next topic

wadmixfm

is this using your mod ??

or can it be used with brl system

Lee

wadmixfm

minus the spelling mistakes hehe

    original:TAudioSample = LoadAudioSample("snare.ogg")
     
    reverse:TAudioSample = CreateAudioSample(original.length, orignal.hertz, original.format)
    ReadPointer:Short Ptr  = original.Samples
    WritePointer:Short Ptr = reverse.Samples
     
    For local i%=0 to original.length-1
       WritePointer = ReadPointer[originl.length-1-i]
    Next

:)) :))

wadmixfm

#17
cannot get it to play the sample thats loaded

any insight please

Lee



Midimaster

#18
can you send one of the (non working) audio files as attachment? I will check it and send you the code to reverse it.

the code to reverse the sound depends on the format the file uses.

the code to play it is of course
sound:TSound=LoadSound(reverse)
PlaySound sound

this is traditionalBlitzMax TSound approach. You do not need MiniAudio to reverse sounds. (But you can of course too)

sorry for the typos. but I wrote it direct into the post without checking it in the IDE. I was only for showing the way, not for copying it.

...back from Egypt

wadmixfm

Thanks peter :)

i am just about to upload my SpecDrum Clone

the other day you wrote to me and asked about my Spectrum clone :)

Noooo this is a drum machine simulation of an old piece of Spectrum software

Lee

wadmixfm

i am having a little trouble uploading my zip files

is it because i am new

lee


wadmixfm

here you go peter i cannot get this working

have a look please

lee

Import mima.miniaudio
Global MiniAudio:TMiniAudio=New TMiniAudio
Function MyCallBack(a:Byte Ptr, PlayBuffer:Short Ptr, RecordingBuffer:Short Ptr, Frames%)
' do something with the samples
End Function
MiniAudio.OpenDevice( MiniAudio.PLAYBACK, Miniaudio.FORMAT_S16, 2, 44000, MyCallBack)

MiniAudio.StartDevice()

Local original:TAudioSample = LoadAudioSample("C:\Users\Public\Specdrum\Kits\Standard\02 Snare.ogg")
     
Local reverse:TAudioSample = CreateAudioSample(original.length, original.hertz, original.format)
Local ReadPointer:Short Ptr  = original.Samples
Local WritePointer:Short Ptr = reverse.Samples
     
For Local i%=0 To original.length-1
WritePointer = ReadPointer[original.length-1-i]
Next
Local sound:TSound = LoadSound(reverse)
PlaySound sound

Input "Press any key to continue"

Midimaster

#22
you had a little typo in the code:
WritePointer = ReadPointer[original.length-1-i]
needs to be:WritePointer[i] = ReadPointer[original.length-1-i]

and there is no need for using the miniaudio. so this is enough:
Code (BlitzMax) Select
Local original:TAudioSample = LoadAudioSample("Snare.ogg")
Print original.format + " " +   SF_STEREO16LE   
Print original.hertz
Print original.length
Local reverse:TAudioSample = CreateAudioSample(original.length, original.hertz, original.format)
Local ReadPointer:Short Ptr  = original.Samples
Local WritePointer:Short Ptr = reverse.Samples
     
For Local i%=0 To original.length-1
WritePointer[i] = ReadPointer[original.length-1-i]
Next
Local sound:TSound = LoadSound(reverse)
PlaySound sound

Input "Press any key to continue"
...back from Egypt

wadmixfm

#23
i am using the miniaudio because its on windows only

and its just imported into the main program you see so i thought i would use it as my program uses it and even though i want the samples reversed i still need to hear them with the latency provided especially when a key is pressed , with miniaudio its instantaneous but with directsound or freeaudio its 150ms to 180ms and its now very noticeable.
Quoteyou had a little typo in the code:
Code: WritePointer = ReadPointer[original.length-1-i]

Quote
needs to be:Code: WritePointer = ReadPointer[original.length-1-i]
This is the code you sent me :)

Lee

wadmixfm

incidentally once the file has been reversed , can i just save out the file using the file options?
lee



Midimaster

Quote from: wadmixfm on June 13, 2021, 14:38:04
incidentally once the file has been reversed , can i just save out the file using the file options?
lee
therefore you would now need MiniAudio. But also with MiniAudio it is only possible to save it as WAV, not as OGG. So why not keep the orignal and during loading you build the reversed sound too.
...back from Egypt

wadmixfm

#26
no its because i have a drumkit editor and saving them as wavs is not feasible.

not to worry i will edit my code so that my program loads them into memory and when you press R to reverse them it will save that file to the kit folder you are creating

i will use my audio editor to create the reversed sounds and stick them in each drum folder as 01 murD ssaB and over the slot will add the R so the user knows its Reversed :)

its a cheats way but there are only 10 samples per folder each sample is about 1 sec in length so each one is around 6k

not too bad

lee


Midimaster

#27
Quote from: wadmixfm on June 13, 2021, 01:20:31
here you go peter i cannot get this working
..
Import mima.miniaudio
Global MiniAudio:TMiniAudio=New TMiniAudio
Function MyCallBack(a:Byte Ptr, PlayBuffer:Short Ptr, RecordingBuffer:Short Ptr, Frames%)
' do something with the samples
End Function
MiniAudio.OpenDevice( MiniAudio.PLAYBACK, Miniaudio.FORMAT_S16, 2, 44000, MyCallBack)

MiniAudio.StartDevice()

Local original:TAudioSample = LoadAudioSample("C:\Users\Public\Specdrum\Kits\Standard\02 Snare.ogg")
...
Local sound:TSound = LoadSound(original)
PlaySound sound

Input "Press any key to continue"


The way you tried to implement MiniAudio does not work that way! As long as use PlaySound() you still do not use the MiniAudio-Library. Using MiniAudio would mean to have a complete different approach. PlaySound() still uses the old FreeSoundDriver even when you defined MiniAudio.

As long as you are happy with PlaySound() there is no need to use MiniAudio. PlaySound() has a lot of advantages and is still the "state of art"-way of firing audios. Only if you feel any limitation of PlaySound() you might want to chance to Miniaudio. But this means to complete design new your audio code.

With MiniAudio you have no longer something like a PlaySound() command. You would fire your samples via the MyCallBack() directly into the "speakers". It is like a last central port where you can only throw in "already mixed final sample values". 10msec later they are already at the speaker. This means if you like to fire two sounds at the same time you would need to combine them "manually" and then fire the result into the MyCallBack.

PlaySound() instead uses a big blackbox where you can throw in different sounds with various parameters at any time. And the blackbox cares about transforming and mixing them together and puts them into a ringbuffer, from where they are performed, when the time has come. This is very comfortable.

The target of MiniAudio is not to be a replacement for FreeAudio (PlaySound()), but a additional way to fire audios, where Freeaudio has limitations:

  • Capture (Recording)

  • more tracks bejond MONO/STEREO

  • using USB-hardware devices

  • mixing together more that 8 sounds at the same time

  • using high quality formats like 32bit-FLOAT

  • opening MP3, WAV, FLAC, multichannel-OGG

As long as you need none of these features there is no reason to use MiniAudio.




...back from Egypt

Midimaster

Reverse Sounds

Why not use a "LoadReverse()" function instead of adding all the files a second time?

Quote from: wadmixfm on June 13, 2021, 20:17:28
i will use my audio editor to create the reversed sounds and stick them in each drum folder as 01 murD ssaB and over the slot will add the R so the user knows its Reversed :)
its a cheats way but there are only 10 samples per folder each sample is about 1 sec in length so each one is around 6k
lee

Code (BlitzMax) Select
Local MyReverseSnare:TAudioSample=LoadReverseAudioSample("Snare.ogg")

Function LoadReverseAudioSample:TAudioSample(Url:String)
Local temp:TAudioSample = LoadAudioSample(Url)
Local reverse:TAudioSample = CreateAudioSample(temp.length, temp.hertz, temp.format)
Local ReadPointer:Short Ptr  = temp.Samples
Local WritePointer:Short Ptr = reverse.Samples     
For Local i:Int=0 To temp.length-1
WritePointer[i] = ReadPointer[temp.length-1-i]
Next
Return reverse
End Function
...back from Egypt

wadmixfm

hmmmmm ok explain this to me then

when using freeaudio on windows 10 without your miniaudio being present i get a latency of 130ms and using playsound

but when i add your driver like in the code and use playsound the latency drops to 20ms

whats running my sound ???

its not using directsound freeaudio or and brl audio system because i have not imported them

lee