1
1
defmodule NxSignal do
2
2
@ moduledoc """
3
- Nx library extension for DSP
3
+ Nx library extension for digital signal processing.
4
4
"""
5
5
6
6
import Nx.Defn
@@ -85,7 +85,7 @@ defmodule NxSignal do
85
85
stft_n ( data , window , sampling_rate , Keyword . put ( opts , :overlap_length , overlap_length ) )
86
86
end
87
87
88
- defnp stft_n ( data , window , sampling_rate , opts \\ [ ] ) do
88
+ defnp stft_n ( data , window , sampling_rate , opts ) do
89
89
{ frame_length } = Nx . shape ( window )
90
90
padding = opts [ :window_padding ]
91
91
fft_length = opts [ :fft_length ]
@@ -252,16 +252,16 @@ defmodule NxSignal do
252
252
end
253
253
end
254
254
255
- deftransformp as_windowed_parse_opts ( shape , opts , :reflect ) do
255
+ deftransformp as_windowed_parse_reflect_opts ( shape , opts ) do
256
256
window_length = opts [ :window_length ]
257
257
258
- as_windowed_parse_opts (
258
+ as_windowed_parse_non_reflect_opts (
259
259
shape ,
260
260
Keyword . put ( opts , :padding , [ { div ( window_length , 2 ) , div ( window_length , 2 ) - 1 } ] )
261
261
)
262
262
end
263
263
264
- deftransformp as_windowed_parse_opts ( shape , opts ) do
264
+ deftransformp as_windowed_parse_non_reflect_opts ( shape , opts ) do
265
265
opts = Keyword . validate! ( opts , [ :window_length , padding: :valid , stride: 1 ] )
266
266
window_length = opts [ :window_length ]
267
267
window_dimensions = { window_length }
@@ -331,7 +331,7 @@ defmodule NxSignal do
331
331
defnp as_windowed_non_reflect_padding ( tensor , opts \\ [ ] ) do
332
332
# current implementation only supports windowing 1D tensors
333
333
{ window_length , stride , padding , output_shape } =
334
- as_windowed_parse_opts ( Nx . shape ( tensor ) , opts )
334
+ as_windowed_parse_non_reflect_opts ( Nx . shape ( tensor ) , opts )
335
335
336
336
output = Nx . broadcast ( Nx . tensor ( 0 , type: tensor . type ) , output_shape )
337
337
{ num_windows , _ } = Nx . shape ( output )
@@ -356,7 +356,7 @@ defmodule NxSignal do
356
356
defnp as_windowed_reflect_padding ( tensor , opts \\ [ ] ) do
357
357
# current implementation only supports windowing 1D tensors
358
358
{ window_length , stride , _padding , output_shape } =
359
- as_windowed_parse_opts ( Nx . shape ( tensor ) , opts , :reflect )
359
+ as_windowed_parse_reflect_opts ( Nx . shape ( tensor ) , opts )
360
360
361
361
output = Nx . broadcast ( Nx . tensor ( 0 , type: tensor . type ) , output_shape )
362
362
{ num_windows , _ } = Nx . shape ( output )
@@ -489,7 +489,7 @@ defmodule NxSignal do
489
489
)
490
490
end
491
491
492
- defnp mel_filters_n ( sampling_rate , max_mel , f_sp , opts \\ [ ] ) do
492
+ defnp mel_filters_n ( sampling_rate , max_mel , f_sp , opts ) do
493
493
fft_length = opts [ :fft_length ]
494
494
mel_bins = opts [ :mel_bins ]
495
495
type = opts [ :type ]
0 commit comments