-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdisplay.jl
More file actions
48 lines (39 loc) · 917 Bytes
/
display.jl
File metadata and controls
48 lines (39 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using .GLMakie
export waveplot, specplot, test
"""
test()
"""
function test()
x = range(0, 10, length=100)
y = sin.(x)
lines(x, y)
end
"""
specplot(audio::Sample{T,N}, fs = 44100Hz)
Draws spectrogram of an audio
# Example
```julia
using GLMakie
audio_one_channel = SampleBuf(rand(1000), 10)
specplot(audio_one_channel,22100)
```
"""
function specplot(audio::SampleBuf{T,N}, fs = 44100) where {T,N}
n = length(audio.data)
nw = n÷50
spec = spectrogram(mono(audio).data, nw, nw÷2; fs=fs)
Makie.heatmap(spec.time, spec.freq, pow2db.(spec.power))
end
"""
waveplot(audio::Sample{T,N}, fs = 44100Hz)
Draws waveplot of a audio
# Example
```julia
using GLMakie
audio_one_channel = SampleBuf(rand(1000), 10)
waveplot(audio_one_channel,48000)
```
"""
function waveplot(audio::SampleBuf{T,N}, fs = 44100) where {T,N}
lines(0:1/fs:(length(mono(audio))-1)/fs, mono(audio))
end