That is not true.
directsound only supports the officiel Microsoft Chunks (RIFF FMT DATA).
Blitzbasic dont use directsound but fmod 3.x. This engine supports the SMPL chuck and only open an output stream to directsound...nothing more.
to remove the SMPL you can also only use an editor who ignore that. As i now AUDACITY also ignore SMPL.
bye
;Abrexxes 2007
;With this you can read, write a wav header and make sample loops for blitzbasic.
;You dont need Loopsound () but make perfect loops. ;)
;You dont need this global, but you can use it to see the data size of your wav file for max value
Global s_datalenght%
Graphics 640,480,0,2
SetBuffer BackBuffer ()
;LoadLoopSound("test.wav",0,0) ; no loop
LoadLoopSound("test.wav",1,s_datalenght) ; maximum loop
;LoadLoopSound("test.wav",800,8000) ; what you want but not more then datalenght
musik = LoadSound ("s_temp.wav")
DeleteFile "s_temp.wav"
While Not KeyHit (1)
Cls
If KeyHit (57) Then
PlaySound (musik)
EndIf
Text 10,10,"Press space to play"
Text 10,20, "Datasize = "+s_datalenght
Flip
Wend
End
Function LoadLoopSound(s_file$,s_start%,s_end%)
;**********************************
;**** Read Source Wav File *****
;**********************************
s_source = ReadFile (s_file)
; read RIFF header (1179011410) to see if it is a wav file
s_check = ReadInt (s_source)
If s_check = 1179011410 Then ; RIFF found
s_check = ReadInt (s_source)
s_sourcesize = (s_check + 8) ; size of sourcefile
s_check = ReadInt (s_source) ; read "wave"
EndIf
If Not s_check = 1163280727 Then Return 0 ; no wave..go away with that :)
; search and read FMT chunk for sample infos
s_position = 12
s_goal = 0
Repeat
SeekFile s_source, s_position
s_check = ReadInt (s_source)
If s_check = 544501094 Then ; FMT found
s_goal = 1 ; now lets read and store all the infos
s_fmtsize = ReadInt (s_source) ;<fmt length> size of this chunk, normal = 16 byte from here
s_format = ReadShort (s_source) ;<format tag> sample format, normal = 1 (hex) for PCM
s_channels = ReadShort (s_source) ;<channels> 1 = mono, 2 = stereo
s_rate = ReadInt (s_source) ;<sample rate> (hz)
s_bytes = ReadInt (s_source) ;<bytes/second> Sample-Rate * Block-Align
s_block = ReadShort (s_source) ;<block align> Channels * bits/sample / 8
s_bit = ReadShort (s_source) ;<bits/sample> 8, 16 or 24
EndIf
s_position = s_position +1 ;FMT not found, next step
If s_goal = 1 Then Exit ; ok
Until Eof (s_source) = 1
If s_goal = 0 Then Return 0 ; no FMT found, Error
; search and read DATA chunk
s_position =12
s_goal = 0
Repeat
SeekFile s_source, s_position
s_check = ReadInt (s_source)
If s_check = 1635017060 Then ; DATA found
s_goal = 1
s_datalenght = ReadInt (s_source) ;<length> of data block
sbank_cache = CreateBank (s_datalenght) ; now we store the sample data
For i = 0 To (s_datalenght-1)
s_value = ReadByte (s_source)
PokeByte sbank_cache,i,s_value
Next
EndIf
s_position = s_position +1 ; DATA not found, next step
If s_goal = 1 Then Exit ; ok
Until Eof (s_source) = 1
If s_goal = 0 Then Return 0 ; no DATA found, Error
CloseFile s_source ; we have what we need, all other chunks we can ignore
;**********************************
;**** Write temp Wav File *****
;**********************************
s_temp = WriteFile ("s_temp.wav") ; create a temp
;write RIFF header
WriteInt s_temp, 1179011410 ; RIFF
WriteInt s_temp, s_sourcesize-8 ;size of header
WriteInt s_temp, 1163280727 ; WAVE
;write FMT chunk
WriteInt s_temp, 544501094 ; FMT
WriteInt s_temp, s_fmtsize ;<fmt length>
WriteShort s_temp, s_format ;<format tag>
WriteShort s_temp, s_channels ;<channels>
WriteInt s_temp, s_rate ;<sample rate>
WriteInt s_temp, s_bytes ;<bytes/second>
WriteShort s_temp, s_block ;<block align>
WriteShort s_temp, s_bit ;<bits/sample>
;write SMPL chunk
WriteInt s_temp, 1819307379 ;SMPL
WriteInt s_temp, 60 ;36 + 1 sample loop section (24)
WriteInt s_temp, 0 ; Manufacturer , we dont need
WriteInt s_temp, 0 ; ProductID , we dont need
WriteInt s_temp, 0 ;Sample Period ,not supported by blitzbasic
WriteInt s_temp, 0 ;MIDI Unity Note ,not supported by blitzbasic
WriteInt s_temp, 0 ;MIDI Pitch Fraction ,not supported by blitzbasic
WriteInt s_temp, 0 ;SMPTE Format ,not supported by blitzbasic
WriteInt s_temp, 0 ;SMPTE Offset ,not supported by blitzbasic
WriteInt s_temp, 0 ;Num Sample Loops ,not supported by blitzbasic
WriteInt s_temp, 0 ;Sampler Data ,not supported by blitzbasic
WriteInt s_temp, 0 ;Cue Point ,not supported by blitzbasic
WriteInt s_temp, 0 ;Type ,not supported by blitzbasic
WriteInt s_temp, s_start ; Start loop
WriteInt s_temp, s_end ;End loop
WriteInt s_temp, 0 ;Fraction ,not supported by blitzbasic
WriteInt s_temp, 0 ;Play Count ,not supported by blitzbasic
;write DATA chunk & data
WriteInt s_temp, 1635017060 ; DATA
WriteInt s_temp, s_datalenght ;<length>
WriteBytes (sbank_cache,s_temp,0,s_datalenght) ;sample data from bank
FreeBank sbank_cache ; we no need this longer
CloseFile s_temp
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D