fb:porticula NoPaste
FMOD-Test (Aufnhame)
Uploader: | Jojo |
Datum/Zeit: | 11.03.2008 21:32:42 |
' Matthew Hart
' DNET4
' 02090201
' 10-01-06
Option Explicit
#INCLUDE ONCE "fmod.bi"
Const FALSE = 0
SCREENRES 640,480,8,1',&h1
If( FSOUND_Init(44100, 32, 0) = FALSE ) Then
Print "Can't initialize FMOD"
End 1
End If
Const buffersize = 2^11
Const bufferbytes = Int(buffersize/2)
Dim Rec_Buffer As Integer
' for sample lock
Dim s_ptr1 As Integer Ptr
Dim s_ptr2 As Integer Ptr
Dim offset As Integer
Dim length As Integer
Dim s_len1 As Unsigned Integer
Dim s_len2 As Unsigned Integer
Dim i As Integer ' for looping
Dim c As Integer ' for palette
Dim c1 As Ubyte
Dim x As Integer
' create the palette
For i = 0 To 255
If i > 127 Then c = i*2
If i > 192 Then c1 = i * 1.7
Palette i,i,c,c1
Next i
Dim As Integer Rpos,jo
Dim j As Double ' holds osciliscope y
Dim y As Integer
y = 240
Cls
Pset (-2,240),255
Color 255
' start the record buffer
Rec_Buffer = FSOUND_SAMPLE_Alloc (FSOUND_FREE, buffersize, FSOUND_NORMAL, 44100, 100, 0, 1)
FSOUND_Record_StartSample ( Rec_Buffer, 1)
length = 512
open "temp.wav" for binary as #1
dim tempbuf as string
Do
Rpos = (FSOUND_Record_GetPosition())-length
If Rpos < 0 Then
Rpos += Bufferbytes
End If
' for the offset, each sample is 2 BYTES, so an offset of 1 BYTE will give garbage
' lock the sample to return a pointer s_prt1 to the data
If (Rpos And 1) <> 0 Then Rpos += 1
FSOUND_Sample_Lock (Rec_Buffer, Rpos, length, @s_ptr1, @s_ptr2, @s_len1, @s_len2)
SCREENLOCK
' plot buffer contents
Line (0,0)-(639,479),0,bf
Pset (-1,y),255
x = 0
y = 240
tempbuf = ""
For i = 0 To s_len1
put #1,,s_ptr1[i]
'tempbuf += s_ptr1[i]
j = ((s_ptr1[i])*.00000002)+y
If Abs(jo-j) > 5 Then Line -(x,j),255 Else Line -(x,j),160
x+=1
If x > 640 Then x = 0:y += 100:Pset (-1,y),255
jo = j
Next i
'put #1,,tempbuf
FSOUND_Sample_UnLock (Rec_Buffer, @s_ptr1, @s_ptr2, s_len1, s_len2)
Locate 1,1:Print "Real-Time Audio Data Capture - Matthew Hart - DNET4 - 02090201"
SCREENUNLOCK
Sleep 3
Loop While Inkey$ = ""
close #1
FSOUND_Record_Stop
FSOUND_Sample_Free(Rec_Buffer)
FSOUND_Close
Sleep
End