Platforms to show: All Mac Windows Linux Cross-Platform

/Audio/PortAudio Streaming Receiver
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 Receiver
This example is the version from Sun, 17th Mar 2012.
Project "PortAudio Streaming Receiver.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" InitAudio End EventHandler
EventHandler Sub DataAvailable() dim s as string s=me.ReadAll if c=nil then Return if lenb(s)=0 then Return // nothing dim m as MemoryBlock = s if not c.AddFloatAudio(m) then msg "Failed to play audio!" else if c.IsStreamActive<>1 then dim e as integer=c.Start if e<>0 then msg "Audio Error: "+str(e) end if end if end if dim n as double = m.Size/4 'if LastTime=0 then Msg "Received "+str(n)+" frames. "+str(floor(n/((Microseconds-LastTime)/1000000.0)))+" frames/s" LastTime=Microseconds 'else 'ReceiveCount=ReceiveCount+n 'Msg "Received "+str(n)+" frames. "+str(ReceiveCount*(Microseconds-LastTime)/1000000.0)+" frames/s" 'end if 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 PushButton1.Enabled=true End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() PushButton1.Enabled=false sock.Address=EditField1.Text sock.Connect End EventHandler
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control status Inherits Label
ControlInstance status Inherits Label
End Control
EventHandler Sub Close() if c<>Nil then call c.Close sock.Close End EventHandler
Sub InitAudio() dim e as integer po=new PortAudioMBS c=new PortAudioStreamBufferedMBS c.NoUnderflow=True e=c.OpenDefaultStream(1,8000.0) if e=0 then else // On Linux 8000 is not supported? msg "Audio Error: "+str(e)+" with host error: "+str(c.HostError) end if End Sub
Sub msg(s as string) if status<>Nil then status.text=s System.DebugLog s End Sub
Property LastTime As Double
Property ReceiveCount As double
Property c As PortAudioStreamBufferedMBS
Property po As PortAudioMBS
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 Xojo Plugins

Start Chat