From 2b72081bb11adfc905eb0d381f103d533b227319 Mon Sep 17 00:00:00 2001 From: Mandar Chitre Date: Fri, 20 Mar 2020 23:39:33 +0800 Subject: [PATCH] Replace data::Array in SampleBuf and SpectrumBuf with data::AbstractArray to allow array-like objects to be wrapped --- src/SampleBuf.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SampleBuf.jl b/src/SampleBuf.jl index cf80cd4..e9da362 100644 --- a/src/SampleBuf.jl +++ b/src/SampleBuf.jl @@ -9,12 +9,12 @@ buffer will be an MxC matrix. So a 1-second stereo audio buffer sampled at type SampleBuf{Float32, 2}. """ mutable struct SampleBuf{T, N} <: AbstractSampleBuf{T, N} - data::Array{T, N} + data::AbstractArray{T, N} samplerate::Float64 end # define constructor so conversion is applied to `sr` -SampleBuf(arr::Array{T, N}, sr::Real) where {T, N} = SampleBuf{T, N}(arr, sr) +SampleBuf(arr::AbstractArray{T, N}, sr::Real) where {T, N} = SampleBuf{T, N}(arr, sr) """ Represents a multi-channel regularly-sampled buffer representing the frequency- @@ -25,12 +25,12 @@ sampled at 44100Hz with 32-bit floating-point samples in the time domain would have the type SampleBuf{Float32, 2}. """ mutable struct SpectrumBuf{T, N} <: AbstractSampleBuf{T, N} - data::Array{T, N} + data::AbstractArray{T, N} samplerate::Float64 end # define constructor so conversion is applied to `sr` -SpectrumBuf(arr::Array{T, N}, sr::Real) where {T, N} = SpectrumBuf{T, N}(arr, sr) +SpectrumBuf(arr::AbstractArray{T, N}, sr::Real) where {T, N} = SpectrumBuf{T, N}(arr, sr) SampleBuf(T::Type, sr, dims...) = SampleBuf(Array{T}(undef, dims...), sr) SpectrumBuf(T::Type, sr, dims...) = SpectrumBuf(Array{T}(undef, dims...), sr)