Platforms to show: All Mac Windows Linux Cross-Platform

/Audio/PortAudio Streaming Sender
Required plugins for this example: MBS Audio Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Audio/PortAudio Streaming Sender
This example is the version from Sun, 17th Mar 2012.
Project "PortAudio Streaming Sender.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control sock Inherits TCPSocket
ControlInstance sock Inherits TCPSocket
EventHandler Sub Connected() msg "Connected" dim m as MemoryBlock = NewMemoryBlock(8000*5) sock.Write m // send 5 seconds of silence to fill output buffer a little bit. InitAudio End EventHandler
EventHandler Sub Error() if me.LastErrorCode<>102 then MsgBox "Socket error: "+str(me.LastErrorCode) msg "Socket error: "+str(me.LastErrorCode) else msg "Disconnected" end if End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control status Inherits Label
ControlInstance status Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() dim l as integer // we ask for samples in the buffer l=p.ReadFrames(m, m.Size) if l>0 then dim s as string = m.StringValue(0, l*4) sock.Write s Msg "Sending "+str(l)+" frames." end if End EventHandler
End Control
EventHandler Sub Close() timer1.Mode=0 if p<>nil then call p.Close p=nil end if sock.Close End EventHandler
EventHandler Sub Open() sock.Listen End EventHandler
Sub InitAudio() m=newMemoryBlock(4*102400) // read maximum 102400 samples per timer loop p=new PortAudioStreamRecorderMBS(1024*1024*16) dim e as integer = p.OpenDefaultStream(1, 8000.0) if e=0 then if p.Start=0 then Msg "Recording started." timer1.Mode=timer1.ModeMultiple else msg "Failed to start audio recording." end if else msg "Audio Error: "+str(e)+" with host error: "+str(p.HostError.ErrorCode)+" "+p.HostError.ErrorText end if End Sub
Sub msg(s as string) status.text=s System.DebugLog s End Sub
Property m As MemoryBlock
Property p As PortAudioStreamRecorderMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Audio Plugin.

The biggest plugin in space...

MBS FileMaker Plugins

Start Chat