Documentation
¶
Index ¶
- type Device
- type DeviceType
- type Devices
- type NoteRecorder
- func (ar *NoteRecorder) Busy() (recording bool, playing bool)
- func (ar *NoteRecorder) Capture(ctx context.Context) error
- func (ar *NoteRecorder) FreeContext() error
- func (ar *NoteRecorder) HasRecorded() bool
- func (ar *NoteRecorder) OpusFile() ([]byte, error)
- func (ar *NoteRecorder) Playback(ctx context.Context) error
- func (ar *NoteRecorder) RecordInfo() RecordInfo
- func (ar *NoteRecorder) SetCaptureDevice(dev *Device) error
- func (ar *NoteRecorder) SetPlaybackDevice(dev *Device) error
- func (ar *NoteRecorder) Stop()
- type OggHeader
- type OggPage
- type OpusPacket
- type RecordInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
IsDefault bool `json:"is_default"`
}
func FindDevice ¶
func FindDevice(typ DeviceType, id string) *Device
FindDevice finds the device with the given ID or returns nil.
type DeviceType ¶
type DeviceType string
const ( DeviceTypeCapture DeviceType = "capture" DeviceTypePlayback DeviceType = "playback" )
type NoteRecorder ¶
type NoteRecorder struct {
// contains filtered or unexported fields
}
NoteRecorder can record and playback audio notes.
func NewRecorder ¶
func NewRecorder(log slog.Logger) (*NoteRecorder, error)
func (*NoteRecorder) Busy ¶
func (ar *NoteRecorder) Busy() (recording bool, playing bool)
Busy returns the state of the recorder.
func (*NoteRecorder) Capture ¶
func (ar *NoteRecorder) Capture(ctx context.Context) error
Capture audio data until the context is canceled or Stop() is called.
func (*NoteRecorder) FreeContext ¶
func (ar *NoteRecorder) FreeContext() error
FreeContext releases all resources.
func (*NoteRecorder) HasRecorded ¶
func (ar *NoteRecorder) HasRecorded() bool
HasRecorded returns whether there's a recorded note.
func (*NoteRecorder) OpusFile ¶
func (ar *NoteRecorder) OpusFile() ([]byte, error)
OpusFile encodes the recorded audio note as an opusfile (a .ogg file with opus-encoded audio data).
func (*NoteRecorder) Playback ¶
func (ar *NoteRecorder) Playback(ctx context.Context) error
Playback the recorded audio until it ends or the context is canceled or Stop() is called.
func (*NoteRecorder) RecordInfo ¶
func (ar *NoteRecorder) RecordInfo() RecordInfo
RecordInfo returns information about the latest recording.
func (*NoteRecorder) SetCaptureDevice ¶
func (ar *NoteRecorder) SetCaptureDevice(dev *Device) error
SetCaptureDevice sets the capture device to use for recording. If nil, uses the default device.
func (*NoteRecorder) SetPlaybackDevice ¶
func (ar *NoteRecorder) SetPlaybackDevice(dev *Device) error
SetPlaybackDevice sets the playback device to use for playing. If nil, uses the default device.
func (*NoteRecorder) Stop ¶
func (ar *NoteRecorder) Stop()
Stop the current operation (record or playback).
type OpusPacket ¶
type OpusPacket []byte