@@ -178,7 +178,6 @@ pub struct SpectrogramProcessor {
178178 hilbert_buf : Vec < Complex32 > ,
179179 spectrum : Vec < Complex32 > ,
180180 scratch : Vec < Complex32 > ,
181- classic_bins : Vec < u16 > ,
182181 reassign : ReassignmentBuffers ,
183182 bin_norm : Vec < f32 > ,
184183 reassigned_power_scale : f32 ,
@@ -206,7 +205,6 @@ impl SpectrogramProcessor {
206205 hilbert_buf : Vec :: new ( ) ,
207206 spectrum : Vec :: new ( ) ,
208207 scratch : Vec :: new ( ) ,
209- classic_bins : Vec :: new ( ) ,
210208 reassign : ReassignmentBuffers :: default ( ) ,
211209 bin_norm : Vec :: new ( ) ,
212210 reassigned_power_scale : 1.0 ,
@@ -264,7 +262,6 @@ impl SpectrogramProcessor {
264262 self . classic_fft . get_scratch_len ( )
265263 } ;
266264 resize_trim ( & mut self . scratch , scratch_len, Complex32 :: ZERO ) ;
267- resize_trim ( & mut self . classic_bins , classic_bin_count, 0 ) ;
268265 self . bin_norm = compute_fft_bin_normalization ( & self . window , self . fft_size ) ;
269266 self . reassigned_power_scale = if use_reassignment {
270267 let inv_hilbert_len = ( hilbert_len as f32 ) . recip ( ) ;
@@ -320,8 +317,7 @@ impl SpectrogramProcessor {
320317 let col = if reassignment_enabled {
321318 SpectrogramColumn :: Reassigned ( Vec :: new ( ) )
322319 } else {
323- self . classic_bins [ ..bin_count] . fill ( pack_classic_db ( DB_FLOOR ) ) ;
324- SpectrogramColumn :: Classic ( self . classic_bins [ ..bin_count] . to_vec ( ) )
320+ SpectrogramColumn :: Classic ( vec ! [ pack_classic_db( DB_FLOOR ) ; bin_count] )
325321 } ;
326322 output. push ( col) ;
327323 self . advance_audio ( hop_size) ;
@@ -372,12 +368,7 @@ impl SpectrogramProcessor {
372368 {
373369 break ;
374370 }
375- Self :: compute_classic_bins (
376- & self . spectrum ,
377- & self . bin_norm ,
378- & mut self . classic_bins ,
379- ) ;
380- SpectrogramColumn :: Classic ( self . classic_bins [ ..bin_count] . to_vec ( ) )
371+ SpectrogramColumn :: Classic ( self . classic_bins ( ) )
381372 } ;
382373
383374 output. push ( col) ;
@@ -437,11 +428,14 @@ impl SpectrogramProcessor {
437428 }
438429 }
439430
440- fn compute_classic_bins ( spectrum : & [ Complex32 ] , bin_norm : & [ f32 ] , bins : & mut [ u16 ] ) {
441- for ( i, c) in spectrum. iter ( ) . enumerate ( ) {
442- let power = ( c. re * c. re + c. im * c. im ) * bin_norm[ i] ;
443- bins[ i] = pack_classic_db ( power_to_db ( power, DB_FLOOR ) ) ;
444- }
431+ fn classic_bins ( & self ) -> Vec < u16 > {
432+ self . spectrum
433+ . iter ( )
434+ . zip ( & self . bin_norm )
435+ . map ( |( c, & norm) | {
436+ pack_classic_db ( power_to_db ( ( c. re * c. re + c. im * c. im ) * norm, DB_FLOOR ) )
437+ } )
438+ . collect ( )
445439 }
446440
447441 fn reassigned_points (
0 commit comments