Maybe there is someone who wants to help or just wants to experiment with it in its current state
Let me know what you think.
Note:
Everything is WIP and may change in the future
Updated 08.09.2023
Version: DEV 0.03 (44100 @ 16 bit - 1 Channel)
Include:
Code: Select all
EnableExplicit
;--------------------------------------------------------------------------------------
; RSND - RetroSound @ 16 bit - mono
; Experimental (OLDSCHOOL) Sound Library
; Written in FASM 1.37.30
;--------------------------------------------------------------------------------------
; Version: DEV 0.03
; Author: Mijikai
; Platform: Windows x64
;--------------------------------------------------------------------------------------
; Copyright 2023 by Mijikai all rights reserved
;--------------------------------------------------------------------------------------
; License:
; Attribution-NonCommercial-NoDerivatives 4.0 International:
; https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
;--------------------------------------------------------------------------------------
#RSND_VERSION = $0003
Import "winmm.lib"
EndImport
Import "rsnd.lib"
rsndOpen.i(*Render);<- calls a user defined callback for every speaker cone position
rsndClose.i()
rsndVersion.i()
EndImport
https://www.dropbox.com/scl/fi/1h4e6h0l ... r7jlm&dl=0
--------------------------------------------------------------------------------------
Version: DEV 0.02
Include:
Code: Select all
EnableExplicit
;--------------------------------------------------------------------------------------
; RSND - RetroSound @ 16 bit - mono
; Experimental (OLDSCHOOL) Sound Library
; Written in PureBasic 6.02 (C-Backend)
;--------------------------------------------------------------------------------------
; Version: DEV 0.02
; Author: Mijikai
; Platform: Windows x64
;--------------------------------------------------------------------------------------
; Copyright 2023 by Mijikai all rights reserved
;--------------------------------------------------------------------------------------
; License:
; Attribution-NonCommercial-NoDerivatives 4.0 International:
; https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
;--------------------------------------------------------------------------------------
#RSND_VERSION = $0002
Import "rsnd.lib"
rsndOpen.i(*Render);<- calls a user defined callback for every speaker cone position
rsndFormat.i();<- returns a pointer to a WAVEFORMATEX struct describing the format
rsndClose.i()
rsndVersion.i()
EndImport
Code: Select all
EnableExplicit
;--------------------------------------------------------------------------------------
; RSND - RetroSound @ 16 bit - mono
; Experimental (OLDSCHOOL) Sound Library
; Written in PureBasic 6.02 (C-Backend)
;--------------------------------------------------------------------------------------
; Version: DEV 0.02
; Author: Mijikai
; Platform: Windows x64
;--------------------------------------------------------------------------------------
XIncludeFile "rsnd.pbi"
Procedure.i waveSine(Amplitude.f,Frequence.f);thx @idle :)
Static phase.f
phase + (6.2832 * Frequence) / 44100
If phase > 6.2832
phase - 6.2832
EndIf
ProcedureReturn 32767 * (Amplitude * Sin(phase))
EndProcedure
Procedure.i Render(*Cone.Word)
*Cone\w = waveSine(0.1,440.0);<- generate a sine wave
ProcedureReturn #Null
EndProcedure
Procedure.i Main()
If OpenConsole("rsnd")
If rsndOpen(@Render())
Input()
rsndClose()
EndIf
CloseConsole()
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
https://www.dropbox.com/scl/fi/syr79kzw ... aavei&dl=0
--------------------------------------------------------------------------------------
Version: DEV 0.01
Include:
Code: Select all
EnableExplicit
;--------------------------------------------------------------------------------------
; RSOUND - RetroSound
; Experimental (OLDSCHOOL) Sound Library
; Written in PureBasic 6.02 (C-Backend)
;--------------------------------------------------------------------------------------
; Version: DEV 0.01
; Author: Mijikai
; Platform: Windows x64
;--------------------------------------------------------------------------------------
; Copyright 2023 by Mijikai all rights reserved
;--------------------------------------------------------------------------------------
; License (MAY CHANGE IN THE FUTURE):
; Attribution-NonCommercial-NoDerivatives 4.0 International:
; https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
;--------------------------------------------------------------------------------------
#RSND_VERSION = $0001
Enumeration RSND_FORMAT
#RSND_FORMAT_PCM
#RSND_FORMAT_FLT
EndEnumeration
Import "rsnd.lib"
rsndOpen.i(Format.i,Channels.i,Rate.i,Bits.i)
rsndFormat.i();<- returns a pointer to a WAVEFORMATEX struct
rsndPlay.i(*Sound,Length.i,Copy.i = #False);<- *Sound is the sound buffer, Lenght its size - if Copy is #False the pointer to the buffer is used otherwise the buffer is copied
rsndClose.i();<- cleanup everything
rsndVersion.i()
EndImport
Code: Select all
EnableExplicit
XIncludeFile "rsnd.pbi"
Procedure.i Tone(Volume.i,Duration.i,FrequencyA.i,FrequencyB.i,NoiseA.i,NoiseB.i);<- Code by Joakim L. Christiansen / https://www.purebasic.fr/english/viewtopic.php?t=41844
Protected *format.WAVEFORMATEX
Protected *wave
Protected sample.i
Protected half.d
Protected winc.d
Protected finc.d
Protected ninc.d
Protected freq.d
Protected nois.d
Protected index.i
Protected wdir.i
Protected wavy.d
Protected nlst.i
Protected *note.Word
*format = rsndFormat()
Debug *format\nChannels
sample = *format\wBitsPerSample >> 3
Duration = ((*format\nSamplesPerSec * 0.001) * Duration) * sample
*wave = AllocateMemory(Duration)
If *wave
Volume = (Volume * 0.001) * 32768
half = *format\nSamplesPerSec / FrequencyA
winc = Volume / half
freq = FrequencyA
nois = NoiseA + NoiseB
If FrequencyB
finc = (FrequencyB - FrequencyA) / (Duration * sample)
EndIf
If NoiseB
ninc = (NoiseB - NoiseA) / (Duration * sample)
EndIf
*note = *wave
For index = 0 To Duration Step 2
If FrequencyB
freq + finc
half = *format\nSamplesPerSec / freq
winc = Volume / half
EndIf
If NoiseB
nois + ninc
EndIf
If wdir
If wavy < Volume
wavy + winc
If wavy >= Volume
wdir = 0
EndIf
EndIf
Else
If wavy > - Volume
wavy - winc
If wavy <= - Volume
wdir = 1
EndIf
EndIf
EndIf
If nois
If nlst >= nois
wavy = Random(Volume)
nlst = 0
Else
nlst + 1
EndIf
EndIf
*note\w = wavy
*note + 2
Next
If rsndPlay(*wave,Duration,#True)
ProcedureReturn #True
EndIf
FreeMemory(*wave)
EndIf
ProcedureReturn #False
EndProcedure
Procedure.i Main()
If rsndOpen(#RSND_FORMAT_PCM,1,44100,16)
Tone(80,500,500,1000,0,0)
Tone(80,400,500,1000,0,0)
Tone(80,100,1500,1000,0,0)
Tone(50,2100,500,1000,0,0)
Tone(80,400,1500,1000,0,0)
OpenConsole(""):Input():CloseConsole()
rsndClose()
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
https://www.dropbox.com/scl/fi/2cos2wpb ... lqegg&dl=0