Audio beep @ 192k and 24 bits
Re: Audio beep @ 192k and 24 bits
Hi Simo_na,
you can use the RME Analyser (DIGICheck). This is a very good Analyser.
you can use the RME Analyser (DIGICheck). This is a very good Analyser.
macOS Catalina 10.15.7
Re: Audio beep @ 192k and 24 bits
Hi,
as mentioned already: Audacity (Freeware)
Bernd
as mentioned already: Audacity (Freeware)
Bernd
Re: Audio beep @ 192k and 24 bits
Hi Wolfram, with DIGICheck also sweep...Wolfram wrote:Hi Simo_na,
you can use the RME Analyser (DIGICheck). This is a very good Analyser.

and DIGICheck does not drop over -50dBfs

Re: Audio beep @ 192k and 24 bits
Thank you Infratec for your work, now i will try it with Audacity ...infratec wrote:Hi,
as mentioned already: Audacity (Freeware)
Bernd

Re: Audio beep @ 192k and 24 bits
the same with audacity




Re: Audio beep @ 192k and 24 bits
Hi,
found something
If you add the if line after r + SineStep it works.
But why ???
I changed my last listing.
Bernd
found something

If you add the if line after r + SineStep it works.
Code: Select all
r + SineStep
If r > #PI * 2 : r - #PI * 2 : EndIf
I changed my last listing.
Bernd
Re: Audio beep @ 192k and 24 bits
Maybe it's a float problem:
Bernd
Code: Select all
Define SineStep.f, i.i, r1.f, r2.f, s1.f, s2.f
SineStep = 0.002
For i = 0 To 1000000
s1 = Sin(r1)
s2 = Sin(r2)
If s1 <> s2
If Abs(s1 - s2) > 0.1
Debug i
Debug ""
Debug r1
Debug s1
Debug Sin(r1)
Debug ""
Debug r2
Debug s2
Debug Sin(r2)
Debug "-----"
Break
EndIf
EndIf
r1 + SineStep
r2 + SineStep
If r2 > #PI * 2 : r2 - #PI * 2 : EndIf
Next i
Re: Audio beep @ 192k and 24 bits
now work fine !!
from 'BasicallyPure' code: (kindred??)
If La > #PIx2 : La - #PIx2 : EndIf ; limit to 2*PI radians



from 'BasicallyPure' code: (kindred??)
If La > #PIx2 : La - #PIx2 : EndIf ; limit to 2*PI radians
Re: Audio beep @ 192k and 24 bits
This is my personal version for very long beeps
now the code work very fine, this is 997 Hz

(thank you^PI)

now the code work very fine, this is 997 Hz

(thank you^PI)

Code: Select all
EnableExplicit
Structure RIFFStructure
Riff.a[4]
Length.l
Wave.a[4]
EndStructure
Structure fmtStructure
fmt.a[4]
Length.l
Format.u
Channels.u
SampleRate.l
BytesPerSecond.l
BlockAlign.u
BitsPerSample.u
EndStructure
Structure dataStructure
Signature.a[4]
Length.l
EndStructure
Procedure.i CreateSineWAV(*WAVBuffer,Freq.i=997,DurationMs.i=10000)
Protected.i Result,dataOffset,Ptr,i,Value,MaxAmp,twi=2,zer=0,eit=8,one=1,fou=4,sixt=16,sarat=192000,bitsam=24,sev=7
Protected.f SineStep,r,twf=2.0,durfix=1000.0,eitw=0.8
Protected *RiffPtr.RIFFStructure,*fmtPtr.fmtStructure,*dataPtr.dataStructure
If *WAVBuffer
*RiffPtr=*WAVBuffer
PokeS(@*RiffPtr\Riff,"RIFF",fou,#PB_Ascii|#PB_String_NoZero)
PokeS(@*RiffPtr\Wave,"WAVE",fou,#PB_Ascii|#PB_String_NoZero)
*fmtPtr=*WAVBuffer+SizeOf(RIFFStructure)
PokeS(@*fmtPtr\fmt,"fmt ",fou,#PB_Ascii|#PB_String_NoZero)
*fmtPtr\Length=SizeOf(fmtStructure)-eit
*fmtPtr\Format=one
*fmtPtr\Channels=one
*fmtPtr\SampleRate=sarat
*fmtPtr\BitsPerSample=bitsam
*fmtPtr\BlockAlign=*fmtPtr\Channels*((*fmtPtr\BitsPerSample+sev) / eit)
*fmtPtr\BytesPerSecond=*fmtPtr\SampleRate**fmtPtr\BlockAlign
*dataPtr=*WAVBuffer+SizeOf(RIFFStructure)+SizeOf(fmtStructure)
PokeS(@*dataPtr\Signature,"data",fou,#PB_Ascii|#PB_String_NoZero)
dataOffset=SizeOf(RIFFStructure)+SizeOf(fmtStructure)+SizeOf(dataStructure)
Ptr=zer
SineStep=#PI*twf*Freq / *fmtPtr\SampleRate
r=zer
MaxAmp=((twi<<(*fmtPtr\BitsPerSample-twi))-one)*eitw
Repeat
Value=Sin(r)*MaxAmp
r+SineStep
If r > #PI*twf : r-#PI*twf : EndIf
PokeA(*WAVBuffer+dataOffset+Ptr,Value & $FF)
Ptr+one
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>eit) & $FF)
Ptr+one
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>sixt) & $FF)
Ptr+one
Until Ptr >= *fmtPtr\BytesPerSecond / durfix*DurationMs
*dataPtr\Length=Ptr
*RiffPtr\Length=SizeOf(RIFFStructure)+SizeOf(fmtStructure)+SizeOf(dataStructure)+Ptr-eit
Result=*RiffPtr\Length+eit
EndIf
ProcedureReturn Result
EndProcedure
InitSound()
Define *Buffer,Length.i,mydura.i,myfreq.i
mydura=10000 ; duration
myfreq=997 ; frequency
*Buffer=AllocateMemory(mydura*myfreq*2)
If *Buffer
Length=CreateSineWAV(*Buffer,myfreq,mydura)
If Length
If CreateFile(0,"c:\tmp\test.wav")
WriteData(0,*Buffer,Length)
CloseFile(0)
EndIf
If CatchSound(0,*Buffer,Length)
PlaySound(0)
While SoundStatus(0)=#PB_Sound_Playing
Delay(10)
Wend
EndIf
EndIf
FreeMemory(*Buffer)
EndIf
Re: Audio beep @ 192k and 24 bits
Thanks a lot for this code.
I set mydura to 1000
I set myfreq to 289. It works fine.
I set myfreq to 288. It works fine, but with F5, it says "The debugged executable quit unexpectedly" after a few seconds. The .exe takes somes seconds to quit (hourglass end).
I set myfreq to 285. The same as 288.
I set myfreq to 284. It does not work.
With F5, "Invalid memory access. (write error at address 84590592)
and the line 57 is red:
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>eit) & $FF)
The .exe does not play any sound, and stops after some seconds of hourglass.
I set mydura to 1000
I set myfreq to 289. It works fine.
I set myfreq to 288. It works fine, but with F5, it says "The debugged executable quit unexpectedly" after a few seconds. The .exe takes somes seconds to quit (hourglass end).
I set myfreq to 285. The same as 288.
I set myfreq to 284. It does not work.
With F5, "Invalid memory access. (write error at address 84590592)
and the line 57 is red:
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>eit) & $FF)
The .exe does not play any sound, and stops after some seconds of hourglass.
PureBasic 6.20 beta 2 (x64) | Windows 10 Pro x64 | Intel(R) Core(TM) i7-8700 CPU @ 3.20Ghz 16 GB RAM, SSD 500 GB, PC locally assembled.
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).
Re: Audio beep @ 192k and 24 bits
Hello,
When I set "myfreq=220", I have an abort at after the repeat in CreateSineWAV().
When I change the line
by
after InitSound(),
the abort disappears, and it works. And It works for all frequency, at least from 1 to 20000 Hz.
Of course, I had to declare new variables in the root, and add them as parameters in the procedure CreateSineWAV().
Thanks to Froggerprogger Date: 11. March 2005
http://www.purearea.net/pb/CodeArchiv/M ... nMemory.pb
His code is more understable, but has too many compilator errors with the actual Purebasic version.
The code working:
When I set "myfreq=220", I have an abort at
Code: Select all
PokeA(*WAVBuffer+dataOffset+Ptr,Value & $FF)
When I change the line
Code: Select all
*Buffer=AllocateMemory(mydura*myfreq*2)
Code: Select all
*Buffer = AllocateMemory(44 + (mydura/1000)*sarat * channel * (bitsam / 8))
the abort disappears, and it works. And It works for all frequency, at least from 1 to 20000 Hz.
Of course, I had to declare new variables in the root, and add them as parameters in the procedure CreateSineWAV().
Thanks to Froggerprogger Date: 11. March 2005
http://www.purearea.net/pb/CodeArchiv/M ... nMemory.pb
His code is more understable, but has too many compilator errors with the actual Purebasic version.
The code working:
Code: Select all
EnableExplicit
Structure RIFFStructure
Riff.a[4]
Length.l
Wave.a[4]
EndStructure
Structure fmtStructure
fmt.a[4]
Length.l
Format.u
Channels.u
SampleRate.l
BytesPerSecond.l
BlockAlign.u
BitsPerSample.u
EndStructure
Structure dataStructure
Signature.a[4]
Length.l
EndStructure
Procedure.i CreateSineWAV(*WAVBuffer,Freq.i,DurationMs.i,sarat.i,Channel.i,bitsam.i)
Protected.i Result,dataOffset,Ptr,i,Value,MaxAmp,twi=2,zer=0,eit=8,one=1,fou=4,sixt=16,sev=7
Protected.f SineStep,r,twf=2.0,durfix=1000.0,eitw=0.8
Protected *RiffPtr.RIFFStructure,*fmtPtr.fmtStructure,*dataPtr.dataStructure
If *WAVBuffer
*RiffPtr=*WAVBuffer
PokeS(@*RiffPtr\Riff,"RIFF",fou,#PB_Ascii|#PB_String_NoZero)
PokeS(@*RiffPtr\Wave,"WAVE",fou,#PB_Ascii|#PB_String_NoZero)
*fmtPtr=*WAVBuffer+SizeOf(RIFFStructure)
PokeS(@*fmtPtr\fmt,"fmt ",fou,#PB_Ascii|#PB_String_NoZero)
*fmtPtr\Length=SizeOf(fmtStructure)-eit
*fmtPtr\Format=one
*fmtPtr\Channels=Channel
*fmtPtr\SampleRate=sarat
*fmtPtr\BitsPerSample=bitsam
*fmtPtr\BlockAlign=*fmtPtr\Channels*((*fmtPtr\BitsPerSample+sev) / eit)
*fmtPtr\BytesPerSecond=*fmtPtr\SampleRate**fmtPtr\BlockAlign
*dataPtr=*WAVBuffer+SizeOf(RIFFStructure)+SizeOf(fmtStructure)
PokeS(@*dataPtr\Signature,"data",fou,#PB_Ascii|#PB_String_NoZero)
dataOffset=SizeOf(RIFFStructure)+SizeOf(fmtStructure)+SizeOf(dataStructure)
Ptr=zer
SineStep=#PI*twf*Freq / *fmtPtr\SampleRate
r=zer
MaxAmp=((twi<<(*fmtPtr\BitsPerSample-twi))-one)*eitw
Repeat
Value=Sin(r)*MaxAmp
r+SineStep
If r > #PI*twf
r-#PI*twf
EndIf
PokeA(*WAVBuffer+dataOffset+Ptr,Value & $FF)
Ptr+one
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>eit) & $FF)
Ptr+one
PokeA(*WAVBuffer+dataOffset+Ptr,(Value>>sixt) & $FF)
Ptr+one
Until Ptr >= *fmtPtr\BytesPerSecond / durfix*DurationMs
*dataPtr\Length=Ptr
*RiffPtr\Length=SizeOf(RIFFStructure)+SizeOf(fmtStructure)+SizeOf(dataStructure)+Ptr-eit
Result=*RiffPtr\Length+eit
EndIf
ProcedureReturn Result
EndProcedure
InitSound()
Define *Buffer,Length.i,mydura.i,myfreq.i,sarat.i,Channel.i,bitsam.i
mydura=1000 ; duration
myfreq=20000 ; frequency
sarat=192000; sample rate
Channel=1
bitsam=24 ; bitrate
; *Buffer=AllocateMemory(mydura*myfreq*2)
*Buffer = AllocateMemory(44 + (mydura/1000)*sarat * channel * (bitsam / 8)) ; V03
Length=CreateSineWAV(*Buffer,myfreq,mydura,sarat,Channel,bitsam)
If Length
If CreateFile(0,"test_" + Str(mydura) + "_" + Str(myfreq) + ".wav")
WriteData(0,*Buffer,Length)
CloseFile(0)
EndIf
If CatchSound(0,*Buffer,Length)
PlaySound(0)
While SoundStatus(0)=#PB_Sound_Playing
Delay(10)
Wend
EndIf
EndIf
FreeMemory(*Buffer)
PureBasic 6.20 beta 2 (x64) | Windows 10 Pro x64 | Intel(R) Core(TM) i7-8700 CPU @ 3.20Ghz 16 GB RAM, SSD 500 GB, PC locally assembled.
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).
Come back to 6.11 LTS 64 bits because of an issue with #PB_ComboBox_UpperCase in ComboBoxGadget() (Oct. 10, 2024).