Skip to content

Commit a95f6c7

Browse files
committed
Added support for WAV and updated README
1 parent b3725f6 commit a95f6c7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ If you have the Polynomial package installed, you can plot them directly the sam
6060
julia> t = TimeArray(d, rand(length(d),2), ["foo","bar"])
6161
julia> Plotly.plot(t)
6262

63-
If you have the TimeSeries package installed, you can plot them directly by passing a TimeArray argument.
63+
If you have the TimeSeries package installed, you can plot them directly by passing a TimeArray argument.
64+
65+
## Plot WAV Files
66+
julia> using WAV
67+
julia> Plotly.plot(wavread("filename.wav"))
68+
69+
If you have the WAV package installed, you can plot WAV files by passing a call to the wavread function.

src/plot.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,15 @@ if Pkg.installed("TimeSeries") !== nothing
4545
]
4646
return plot([data], options)
4747
end
48+
end
49+
50+
if Pkg.installed("WAV") !== nothing
51+
function plot{T<:Number,U<:Number,V<:Number}(wav::(Array{T,2},U,V,UnionType), options=Dict())
52+
opt = merge(["layout"=>["xaxis"=>["title"=>"seconds","dtick"=>1,"tick0"=>0,"autotick"=>false]]], options)
53+
w, Fs = wav
54+
X = [f/Fs for f in 1.0:length(w)]
55+
Y = [round(y,8) for y in w]
56+
data = [["x"=>X, "y"=>Y, "type"=>"scatter", "mode"=>"lines", "name"=>"WAV data"]]
57+
return plot([data], opt)
58+
end
4859
end

0 commit comments

Comments
 (0)