API
Sources
Each AudioSource
is a subtype of AbstractAudioSource
and allows to load audio data in a unified format.
AudioSources.AbstractAudioSource
— Typeabstract type AbstractAudioSource end
Abstract class for all audio sources. Possible sources are:
CmdAudioSource
FileAudioSource
RawAudioSource
URLAudioSource
Lib:
Recorder
Command
AudioSources.CmdAudioSource
— MethodCmdAudioSource(c::String)
Audio from a command provided as string.
File
AudioSources.FileAudioSource
— TypeFileAudioSource(path::AbstractString)
Audio from a file.
Raw
AudioSources.RawAudioSource
— MethodRawAudioSource(x::AbstractArray, fs)
Audio from an Array.
URL
AudioSources.URLAudioSource
— TypeURLAudioSource(url::AbstractString)
Audio from an URL.
Functions
AudioSources.load
— Functionload(s::AbstractAudioSource, subrange::Union{AbstractRange, Colon} = :, ch=1)
Get the audio data and sampling rate for desired subrange and channel. Return (data, fs)
AudioSources.resample
— Methodresample(s::FileAudioSource, fs::Int64; out=nothing)
Resample a file source.
Base.show
— MethodBase.show(io::IO, ::MIME"text/html", s::AbstractAudioSource)
In HTML context, show an AbstractAudioSource as audio tag.
Recorder Lib
AudioSources.RecorderLib
— ModuleLib to extend AudioSources with an audio recorder. Can be imported with using AudioSources.RecorderLib
Recommanded to use in a notebook, see the example notebook
AudioSources.RecorderLib.Recorder
— Typemutable struct Recorder
Object to store recording parameters and recorded data.
Fields
fs::Int
sampling rate, in Hzchunkduration::Float64
record by chunks of chunkduration lengthchunksize::Int
≈ chunkduration*fschannel::Channel
used for async communicationdata::AbstractArray
store the recorded audiodatatype::DataType
type of the data array elements
AudioSources.RecorderLib.Recorder
— TypeRecorder(; <keyword arguments>)
Initialize Recorder with default values if not specified.
Arguments
fs::Int = 16000
sampling rate, in Hzchunkduration::Float64 = 0.5
record by chunks of chunkduration lengthdatatype::DataType = Float32
data type to store the data, Floats are recommanded
AudioSources.RecorderLib.start
— Functionstart(r::Recorder, erase=true)
Start recording. Recommended to run it asynchronously (@async start(rec)
). Set erase
to true to reset the previously recorded data, otherwise the new recording is appended to the previous one.
AudioSources.RecorderLib.stop
— Methodstop(r::Recorder)
Stop recording.
AudioSources.RecorderLib.recordfor
— Functionrecordfor(r::Recorder, time, erase=true)
Start a recording for given time
(in seconds)
AudioSources.RecorderLib.isrecording
— Methodisrecording(r::Recorder)
Indicate whether or not the Recorder is currently active.
AudioSources.RecorderLib.getduration
— Methodgetduration(r::Recorder)
Give the length of the recording (in seconds).
AudioSources.RecorderLib.RecorderWidget
— Typestruct RecorderWidget
UI component for Recorder.
AudioSources.RecorderLib.RecorderWidget
— MethodRecorderWidget()
Initialize a RecorderWidget. It will be displayed as an HTML button.
Index
AudioSources.RecorderLib
AudioSources.AbstractAudioSource
AudioSources.CmdAudioSource
AudioSources.FileAudioSource
AudioSources.RawAudioSource
AudioSources.RecorderLib.Recorder
AudioSources.RecorderLib.Recorder
AudioSources.RecorderLib.RecorderWidget
AudioSources.RecorderLib.RecorderWidget
AudioSources.URLAudioSource
AudioSources.RecorderLib.getduration
AudioSources.RecorderLib.isrecording
AudioSources.RecorderLib.recordfor
AudioSources.RecorderLib.start
AudioSources.RecorderLib.stop
AudioSources.load
AudioSources.resample
Base.show