Methods list
Sound.SoundSound.findpeaksSound.get_default_input_deviceSound.get_default_output_deviceSound.hannSound.hannSound.phase_vocoderSound.pick_outputSound.recordSound.soundSound.soundSound.soundSound.soundSound.soundSound.soundscSound.soundsc
Methods usage
Sound.Sound — Module
SoundModule that exports wrappers around audio methods in PortAudio.
soundandsoundsc: methods for audio playback.record: method for audio recording.
Sound.findpeaks — Function
findpeaks(amp, max_peak::Int = 50, eps_peak::Real = 0.005)Given a real-valued vector of amplitudes amp, find up to max_peak peaks. Ignores any amplitudes ≤ eps_peak * maxium(amp).
Returns a matrix with 3 columns where each row describes a peak.
Sound.get_default_input_device — Method
get_default_input_device()Determine current system-wide default input audio device.
Sound.get_default_output_device — Method
get_default_output_device()Determine current system-wide default output audio device.
Sound.hann — Method
hann(x::AbstractFloat)Hann window function (often called "Hanning" window function). This version is 0.5 * (1 + cospi(2x)) and used in [-0.5,+0.5]. https://en.wikipedia.org/wiki/Hann_function
Sound.hann — Method
hann(n::Int)Return vector of n ≥ 2 samples of Hann window function equally spaced over [-0.5,+0.5]. The first and last samples are zero for n ≥ 2.
Caution. Matlab has both hann and hanning functions for which [0; hanning(n); 0] == hann(n+2).
DSP.hanning(n) == Matlab.hann(n)whereasSound.hann(n) == Matlab.hanning(n)`.
Sound.phase_vocoder — Function
phase_vocoder(x, sr = framerate(x); kwargs...)Phase vocoder for time scaling of signal x having sampling rate sr in Hz. The time-stretch is determined by the ratio of hopin and hopout variables. For example, hopin=242 and hopout=161.3333 (integers are not required) increases the tempo by hopin/hopout = 1.5. To slow down a comparable amount, choose hopin = 161.3333, hopout = 242.
Option
time::Real = length(x) * sr: total time to process (in sec)hopin::Real = 121: hop length for inputhopout::Real = 2*hopin: hop length for outputall2pi::Any = 2π*(0:100)multiples of 2π (used in PV-style freq search)max_peak::Int = 50: parameters for peak finding: number of peakseps_peak::Real = 0.005: minimum height of peaksnfft::Int = 2^12: fft lengthwin::AbstractVector{<:Real} = hann(nfft): windowT::Type = Float32: data type
Sound.pick_output — Method
pick_output( ; io_in::IO = stdin, io_out::IO = stdout)Show available audio devices and prompt user to select output device.
Sound.record — Function
data, S = record(time::Real = 5; input_device, args=(1,0), chat::Bool=true)Record time seconds of audio data using input_device (typically defaults to the built-in microphone).
Input
time: duration; 5 seconds by default
Option
input_device::PortAudioDevice = get_default_input_device()system defaultargs: arguments to PortAudioStream;(1,0)for single-channel input by defaultchat: show begin/end message?trueby default
Output
data: Vector of lengthtime * SS:sample_rateof input stream
Sound.sound — Function
sound(output_device_index::Int, x, S::Real = framerate(x); kwargs...)Play sound in x using devices()[output_device_index].
Sound.sound — Function
sound(x::AbstractMatrix, S::Real = framerate(x) [, output_device])Play stereo audio signal x at sampling rate S samples per second through default audio output device using the PortAudio package. Caller must specify S unless a framerate method is defined for x.
Sound.sound — Function
sound(x::AbstractVector, S::Real = framerate(x), args...; kwargs...)Play monophonic audio signal x at sampling rate S samples per second through default audio output device using the PortAudio package. Caller must specify S unless a framerate method is defined for x.
Sound.sound — Function
sound(:pick, x, S::Real = framerate(x); kwargs...)Prompt user to pick output device, then play sound in x.
Sound.sound — Method
sound(sb::SampleBuf)Play audio signal sb of type SampleBuf through default audio output device using the PortAudio package.
Sound.soundsc — Function
soundsc(x, S::Real = framerate(x), args...; kwargs...)Call sound after scaling x to have values in (-1,1).
Sound.soundsc — Method
soundsc(sb::SampleBuf)Play audio signal sb of type SampleBuf through default audio output device using the PortAudio package, after scaling the data to have values in (-1,1).