Documentation
¶
Overview ¶
For the most part, these bindings parallel the underlying PortAudio API; please refer to http://www.portaudio.com/docs.html for details. Differences introduced by the bindings are documented here:
Instead of passing a flag to OpenStream, audio sample formats are inferred from the signature of the stream callback or, for a blocking stream, from the types of the buffers. See the StreamCallback and Buffer types for details.
Blocking I/O: Read and Write do not accept buffer arguments; instead they use the buffers (or pointers to buffers) provided to OpenStream. The number of samples to read or write is determined by the size of the buffers.
The StreamParameters struct combines parameters for both the input and the output device as well as the sample rate, buffer size, and flags.
Index ¶
- Constants
- func Initialize() error
- func IsFormatSupported(p StreamParameters, args ...interface{}) error
- func Terminate() error
- func Version() int
- func VersionText() string
- type Buffer
- type DeviceInfo
- type Error
- type HostApiInfo
- type HostApiType
- type Int24
- type Stream
- func (s *Stream) Abort() error
- func (s *Stream) AvailableToRead() (int, error)
- func (s *Stream) AvailableToWrite() (int, error)
- func (s *Stream) Close() error
- func (s *Stream) CpuLoad() float64
- func (s *Stream) Info() *StreamInfo
- func (s *Stream) Read() error
- func (s *Stream) Start() error
- func (s *Stream) Stop() error
- func (s *Stream) Time() time.Duration
- func (s *Stream) Write() error
- type StreamCallback
- type StreamCallbackFlags
- type StreamCallbackTimeInfo
- type StreamDeviceParameters
- type StreamFlags
- type StreamInfo
- type StreamParameters
- type UnanticipatedHostError
Constants ¶
const FramesPerBufferUnspecified = C.paFramesPerBufferUnspecified
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize() error
func IsFormatSupported ¶
func IsFormatSupported(p StreamParameters, args ...interface{}) error
Returns nil if the format is supported, otherwise an error. The args parameter has the same meaning as in OpenStream.
func VersionText ¶
func VersionText() string
Types ¶
type Buffer ¶
type Buffer interface{}
This type exists for documentation purposes only.
A Buffer is of the form [][]SampleType or []SampleType where SampleType is float32, int32, Int24, int16, int8, or uint8.
In the first form, channels are non-interleaved: len(buf) == numChannels and len(buf[i]) == framesPerBuffer
In the second form, channels are interleaved: len(buf) == numChannels * framesPerBuffer
type DeviceInfo ¶
type DeviceInfo struct { Name string MaxInputChannels int MaxOutputChannels int DefaultLowInputLatency time.Duration DefaultLowOutputLatency time.Duration DefaultHighInputLatency time.Duration DefaultHighOutputLatency time.Duration DefaultSampleRate float64 HostApi *HostApiInfo // contains filtered or unexported fields }
func DefaultInputDevice ¶
func DefaultInputDevice() (*DeviceInfo, error)
func DefaultOutputDevice ¶
func DefaultOutputDevice() (*DeviceInfo, error)
func Devices ¶
func Devices() ([]*DeviceInfo, error)
type Error ¶
const ( NotInitialized Error = C.paNotInitialized InvalidChannelCount Error = C.paInvalidChannelCount InvalidSampleRate Error = C.paInvalidSampleRate InvalidDevice Error = C.paInvalidDevice InvalidFlag Error = C.paInvalidFlag SampleFormatNotSupported Error = C.paSampleFormatNotSupported BadIODeviceCombination Error = C.paBadIODeviceCombination InsufficientMemory Error = C.paInsufficientMemory BufferTooBig Error = C.paBufferTooBig BufferTooSmall Error = C.paBufferTooSmall NullCallback Error = C.paNullCallback BadStreamPtr Error = C.paBadStreamPtr TimedOut Error = C.paTimedOut InternalError Error = C.paInternalError IncompatibleHostApiSpecificStreamInfo Error = C.paIncompatibleHostApiSpecificStreamInfo StreamIsStopped Error = C.paStreamIsStopped StreamIsNotStopped Error = C.paStreamIsNotStopped InputOverflowed Error = C.paInputOverflowed OutputUnderflowed Error = C.paOutputUnderflowed HostApiNotFound Error = C.paHostApiNotFound InvalidHostApi Error = C.paInvalidHostApi CanNotReadFromACallbackStream Error = C.paCanNotReadFromACallbackStream CanNotWriteToACallbackStream Error = C.paCanNotWriteToACallbackStream CanNotReadFromAnOutputOnlyStream Error = C.paCanNotReadFromAnOutputOnlyStream CanNotWriteToAnInputOnlyStream Error = C.paCanNotWriteToAnInputOnlyStream IncompatibleStreamHostApi Error = C.paIncompatibleStreamHostApi BadBufferPtr Error = C.paBadBufferPtr )
type HostApiInfo ¶
type HostApiInfo struct { Type HostApiType Name string DefaultInputDevice *DeviceInfo DefaultOutputDevice *DeviceInfo Devices []*DeviceInfo }
func DefaultHostApi ¶
func DefaultHostApi() (*HostApiInfo, error)
func HostApi ¶
func HostApi(apiType HostApiType) (*HostApiInfo, error)
func HostApis ¶
func HostApis() ([]*HostApiInfo, error)
type HostApiType ¶
type HostApiType int
const ( InDevelopment HostApiType = C.paInDevelopment DirectSound HostApiType = C.paDirectSound MME HostApiType = C.paMME ASIO HostApiType = C.paASIO SoundManager HostApiType = C.paSoundManager CoreAudio HostApiType = C.paCoreAudio OSS HostApiType = C.paOSS ALSA HostApiType = C.paALSA AL HostApiType = C.paAL BeOS HostApiType = C.paBeOS WDMkS HostApiType = C.paWDMKS JACK HostApiType = C.paJACK WASAPI HostApiType = C.paWASAPI AudioScienceHPI HostApiType = C.paAudioScienceHPI )
func (HostApiType) String ¶
func (t HostApiType) String() string
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func OpenDefaultStream ¶
func OpenDefaultStream(numInputChannels, numOutputChannels int, sampleRate float64, framesPerBuffer int, args ...interface{}) (*Stream, error)
The args parameter has the same meaning as in OpenStream.
func OpenStream ¶
func OpenStream(p StreamParameters, args ...interface{}) (*Stream, error)
For an input- or output-only stream, p.Output.Device or p.Input.Device must be nil, respectively.
The args may consist of either a single StreamCallback or, for a blocking stream, two Buffers or pointers to Buffers. For an input- or output-only stream, one of the Buffer args may be omitted.
func (*Stream) AvailableToRead ¶
func (*Stream) AvailableToWrite ¶
func (*Stream) Info ¶
func (s *Stream) Info() *StreamInfo
type StreamCallback ¶
type StreamCallback interface{}
This type exists for documentation purposes only.
A StreamCallback is a func whose signature resembles
func(in Buffer, out Buffer, timeInfo StreamCallbackTimeInfo, flags StreamCallbackFlags)
where the final one or two parameters may be omitted. For an input- or output-only stream, one of the Buffer parameters may also be omitted. The two Buffer types may be different.
type StreamCallbackFlags ¶
type StreamCallbackFlags C.PaStreamCallbackFlags
const ( InputUnderflow StreamCallbackFlags = C.paInputUnderflow InputOverflow StreamCallbackFlags = C.paInputOverflow OutputUnderflow StreamCallbackFlags = C.paOutputUnderflow OutputOverflow StreamCallbackFlags = C.paOutputOverflow PrimingOutput StreamCallbackFlags = C.paPrimingOutput )
type StreamCallbackTimeInfo ¶
type StreamDeviceParameters ¶
type StreamDeviceParameters struct { Device *DeviceInfo Channels int Latency time.Duration }
StreamDeviceParameters specifies parameters for one device (either input or output) in a stream. A nil Device indicates that no device is to be used -- i.e., for an input- or output-only stream.
type StreamFlags ¶
type StreamFlags C.PaStreamFlags
const ( NoFlag StreamFlags = C.paNoFlag ClipOff StreamFlags = C.paClipOff DitherOff StreamFlags = C.paDitherOff NeverDropInput StreamFlags = C.paNeverDropInput PrimeOutputBuffersUsingStreamCallback StreamFlags = C.paPrimeOutputBuffersUsingStreamCallback PlatformSpecificFlags StreamFlags = C.paPlatformSpecificFlags )
type StreamInfo ¶
type StreamParameters ¶
type StreamParameters struct {
Input, Output StreamDeviceParameters
SampleRate float64
FramesPerBuffer int
Flags StreamFlags
}
StreamParameters includes all parameters required to open a stream except for the callback or buffers.
func HighLatencyParameters ¶
func HighLatencyParameters(in, out *DeviceInfo) (p StreamParameters)
High latency parameters are mono in, stereo out (if supported), high latency, the smaller of the default sample rates of the two devices, andFramesPerBufferUnspecified. One of the devices may be nil.
func LowLatencyParameters ¶
func LowLatencyParameters(in, out *DeviceInfo) (p StreamParameters)
Low latency parameters are mono in, stereo out (if supported), low latency, the larger of the default sample rates of the two devices, and FramesPerBufferUnspecified. One of the devices may be nil.
type UnanticipatedHostError ¶
type UnanticipatedHostError struct { HostApiType HostApiType Code int Text string }
func (UnanticipatedHostError) Error ¶
func (err UnanticipatedHostError) Error() string