SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => Topic started by: wadmixfm on June 03, 2021, 18:14:35

Title: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 03, 2021, 18:14:35
Its taken a few months to finally get it working !!!!

Many younger people in here may not remember the Specdrum drum machine software for the Spectrum 48k machine
in 1985 it was a very cheap hardware add on for the computer which then the user would load from a tape the software

it was a hit for £25 and it supported 8 samples in memory at once and played them through the hardware which was a dac converter chip which then converted the data to a audio sample ok for its time they were 3bit but at that time was clear enough to use as a drum machine.

The default samples were

1 bass brum
2 snare
3 hi tom
4 lo tom
5 cowbell
6 hi hat closed
7 open hi hat
8 clap

there were 4 kits supplied on cassette

1 Standard kit
2 AfroKit
3 ElectroKit
4 LatinKit

I have made my Specdrum clone as close as i can to the original i have made it available for both Windows and Mac 64bit
i did originally write it with blitzmax 32 bit and then everything went heywire lol 64 bit showed its pretty little face and then blitzmax NG come on to the scene and well i had to rise to the challenge and convert all my code to make it run on 64 bit and its finally done.

i will post some photos from the original and from my version

cheers

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 03, 2021, 18:43:24
here are some old and new pics so far hope they work ok

lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Pingus on June 03, 2021, 21:10:35
Can't wait to see (and hear) a video !
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 04, 2021, 07:10:53
Yes will add video later

Cheers

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: iWasAdam on June 04, 2021, 12:08:42
Great project - I had the datel drum sampler back in the day ;)
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 05, 2021, 22:40:13
can we add videos in here ???? or do they have to be streamed from youtube for example ???

lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 06, 2021, 22:25:24


here is the video :)

please excuse my commentary i cant do voice overs very well :)

lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Steve Elliott on June 06, 2021, 22:39:19
Fantastic work!  I still have a working 48K ZX Spectrum and waiting on a ZX Spectrum Next, so to see your work pushing old hardware is great to see.   8)
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 06, 2021, 22:46:01
 ;D

Thank you :)

Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 06, 2021, 22:52:04
i still use it as i mentioned in the video you can load your own samples in to it and create new kits too with the kit editor

, there is one thing i want to add to it but cant get my head around is reversing the samples , i want some code that can turn the ogg samples around make them play backwards at the flick of a switch and then i can save them

i will work on it

my next update will be using velocity for each note only 3 stages like a low mid and hi velocity on the older drum machines they were called accent.

:)
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 08, 2021, 12:53:11
Are we allowed to post the files here so people can download etc...?

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Steve Elliott on June 08, 2021, 12:54:30
Quote
Are we allowed to post the files here so people can download etc...?

Yes, just attach the files to your post.
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 09, 2021, 22:50:26
cool , i am just cleaning up little bugs i have found and some quicker bits of code then i will upload

1 for mac 64bit and windows 10 64bit :)

lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 12, 2021, 01:39:36
... there is one thing i want to add to it but cant get my head around is reversing the samples , i want some code that can turn the ogg samples around make them play backwards at the flick of a switch and then i can save them
..

This can be done very easy. Create new TAudioSample with the same size and parameters of the original and then copy all samples datas in reverse order from original to new object.


Code: BlitzMax
  1. original:TAudioSample = LoadAudioSample("snare.ogg")
  2.  
  3. reverse:TAudioSample = CreateAudioSample(original.length, orignal.hertz, original.format)
  4. ReadPointer:Short Ptr  = original.Samples
  5. WritePointer:Short Ptr = reverse.Samples
  6.  
  7. For local i%=0 to original.length-1
  8.    WritePointer[i] = ReadPointer[originl.length-1-i]
  9. Next
 
(code not tested, only written on the fly in this post)

works if the audio file uses a 16bit format.
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 12, 2021, 16:28:54
oh thats interesting , will give that a shot

thanks

lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 12, 2021, 17:14:48
is this using your mod ??

or can it be used with brl system

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 12, 2021, 17:48:14
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

 :)) :))
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 12, 2021, 20:07:30
cannot get it to play the sample thats loaded

any insight please

Lee


Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 12, 2021, 21:57:00
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
Code: [Select]
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.

Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 12, 2021, 23:10:33
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
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 13, 2021, 00:01:13
i am having a little trouble uploading my zip files

is it because i am new

lee

Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 13, 2021, 01:20:31
here you go peter i cannot get this working

have a look please

lee

Code: [Select]
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"
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 13, 2021, 09:50:44
you had a little typo in the code:
Code: [Select]
WritePointer = ReadPointer[original.length-1-i]needs to be:
Code: [Select]
WritePointer[i] = ReadPointer[original.length-1-i]
and there is no need for using the miniaudio. so this is enough:
Code: BlitzMax
  1. Local original:TAudioSample = LoadAudioSample("Snare.ogg")
  2. Print original.format + " " +   SF_STEREO16LE  
  3. Print original.hertz
  4. Print original.length
  5. Local reverse:TAudioSample = CreateAudioSample(original.length, original.hertz, original.format)
  6. Local ReadPointer:Short Ptr  = original.Samples
  7. Local WritePointer:Short Ptr = reverse.Samples
  8.      
  9. For Local i%=0 To original.length-1
  10.  WritePointer[i] = ReadPointer[original.length-1-i]
  11. Next
  12. Local sound:TSound = LoadSound(reverse)
  13. PlaySound sound
  14.  
  15. Input "Press any key to continue"
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 13, 2021, 14:32:50
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.
Quote
you 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
Title: Re: I finally Finshed My Specdrum Clone
Post by: 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


Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 13, 2021, 18:58:24
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.
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 13, 2021, 20:17:28
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

 
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 14, 2021, 08:20:37
here you go peter i cannot get this working
..
Code: [Select]
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:
As long as you need none of these features there is no reason to use MiniAudio.




Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 14, 2021, 09:43:13
Reverse Sounds

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

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
  1. Local MyReverseSnare:TAudioSample=LoadReverseAudioSample("Snare.ogg")
  2.  
  3. Function LoadReverseAudioSample:TAudioSample(Url:String)
  4.         Local temp:TAudioSample = LoadAudioSample(Url)
  5.         Local reverse:TAudioSample = CreateAudioSample(temp.length, temp.hertz, temp.format)
  6.         Local ReadPointer:Short Ptr  = temp.Samples
  7.         Local WritePointer:Short Ptr = reverse.Samples      
  8.         For Local i:Int=0 To temp.length-1
  9.                 WritePointer[i] = ReadPointer[temp.length-1-i]
  10.         Next
  11.         Return reverse
  12. End Function
  13.  
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 19:31:50
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
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 19:46:09
i will upload a version without your mod installed and set it to freeaudio

you compare

i have posted the miniaudio version on the Specdrum 2 topic for windows

i will post the freeaudio version install them and you tell me which is fastest

lee

Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 20:40:33
here you go midimaster download this version its all the same code but with freeaudio sdl windows 10 pro 64bit

https://share.bublup.com/ui/landing_page?item_id=001-i-a189011f-1136-43eb-9abb-f191d231e8b4 (https://share.bublup.com/ui/landing_page?item_id=001-i-a189011f-1136-43eb-9abb-f191d231e8b4)

and this version is with your miniaudio added still using playsound

https://share.bublup.com/ui/landing_page?item_id=001-i-5a50eedd-c534-4d97-b163-c6e8e3f10f81 (https://share.bublup.com/ui/landing_page?item_id=001-i-5a50eedd-c534-4d97-b163-c6e8e3f10f81)

and when you test them go into the program and press S on the keys

this will let you play the sounds by hitting the keys

do the freeaudio first

then do yours

and tell me your findings

the only code i added was :-

Code: [Select]
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()

to the top of my program

and it works spot on

no latency at all

Lee


Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 14, 2021, 22:39:04
this sounds strange... FreeAudio has 60msec on Windows if you do not decide any driver but use the default. Without the source code I cannot check what happens.

I downloaded your link and installed the app. But the app did not work as expected. First test was to use the window close button and this did not work. Second strange thing was the manual. It is in DOC-format. Normally I would expect something like a HTML-document or a PDF. But never a (dangerous) DOC.
Third thing was the Menu. The app started with the MIDI-Port selection. After ENTER I could not do anything. The option C was blinking, but there was no reaction on any key. At the end I had to stop the app via TASK MANAGER.


Do you plan to publish the source code too? I would have a look on it.
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 14, 2021, 23:01:12
....
Quote
you 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

Do we still have a problem with brackets in the SyntaxBomb-Software? This is what I see:

Screenshot:
(https://www.syntaxbomb.com/index.php?action=dlattach;topic=8477.0;attach=4651)
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:24:51
Ok run the program

Midi page selection

Press escape

Main menu

At flashing cursor type 1 and press enter

Div beat type 8 press enter

Song info page press escape

Back to main menu

Press S

Hit keys 1 to 0 for the sounds

Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:26:25
Do that on both versions and you will see what i mean
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:27:33
The manual is written word for Microsoft

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:29:20
I will post a video of it tomorrow and show you the differences if you cant get it running
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:30:58
You must make sure it installs to the default install path you cant put it anywhere
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:37:09
The program works fine

You were not choosing the song number
Then you need to type a div beat 8 is suffice
Prwss enter
Then song info
Press escape
Back to main menu all functions work fine

I will convert the manual

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 14, 2021, 23:39:07
If you go back to page 1 of this topic there is a video showing you what to do

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 14, 2021, 23:45:09
with your detail instructions i was able to use both versions now. Your are right there is a significant latency difference between both versions. do you pland to publish the source code?
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 15, 2021, 00:00:41
No there is a lot

But as you see the latency is better with miniaudio in windows but i have not used it on the mac

Lee
Title: Re: I finally Finshed My Specdrum Clone
Post by: Midimaster on June 15, 2021, 00:03:57
but without having a look on the code I cannot find out why the latency changes. I would not have expected this. Do you have any code line related to audio drivers etc...?
Title: Re: I finally Finshed My Specdrum Clone
Post by: wadmixfm on June 15, 2021, 07:45:48
Yeah i will post it later

Lee
SimplePortal 2.3.6 © 2008-2014, SimplePortal