@@ -21,15 +21,15 @@ impl FrequencyPeak {
2121 /// rate, 1024 useful bins and the multiplication by 64 made before
2222 /// storing the information
2323
24- pub fn get_frequency_hz ( self : & Self ) -> f32 {
24+ pub fn get_frequency_hz ( & self ) -> f32 {
2525
2626 self . corrected_peak_frequency_bin as f32 * ( self . sample_rate_hz as f32 / 2.0 / 1024.0 / 64.0 )
2727
2828 }
2929
3030 /// Not sure about this calculation but gives small enough numbers
3131
32- pub fn get_amplitude_pcm ( self : & Self ) -> f32 {
32+ pub fn get_amplitude_pcm ( & self ) -> f32 {
3333
3434 ( ( ( self . peak_magnitude as f32 - 6144.0 ) / 1477.3 ) . exp ( ) * ( ( 1 << 17 ) as f32 ) / 2.0 ) . sqrt ( ) / 1024.0
3535
@@ -38,7 +38,7 @@ impl FrequencyPeak {
3838 /// Assume that new FFT bins are emitted every 128 samples, on a
3939 /// standard 16 KHz sample rate basis.
4040
41- pub fn get_seconds ( self : & Self ) -> f32 {
41+ pub fn get_seconds ( & self ) -> f32 {
4242
4343 ( self . fft_pass_number as f32 * 128.0 ) / self . sample_rate_hz as f32
4444
@@ -174,13 +174,13 @@ impl DecodedSignature {
174174 if !frequency_band_to_sound_peaks. contains_key ( & frequency_band) {
175175 frequency_band_to_sound_peaks. insert ( frequency_band, vec ! [ ] ) ;
176176 }
177-
177+
178178 frequency_band_to_sound_peaks. get_mut ( & frequency_band) . unwrap ( ) . push (
179179 FrequencyPeak {
180- fft_pass_number : fft_pass_number ,
180+ fft_pass_number,
181181 peak_magnitude : frequency_peaks_cursor. read_u16 :: < LittleEndian > ( ) ?,
182182 corrected_peak_frequency_bin : frequency_peaks_cursor. read_u16 :: < LittleEndian > ( ) ?,
183- sample_rate_hz : sample_rate_hz
183+ sample_rate_hz
184184 }
185185 ) ;
186186 }
@@ -210,7 +210,7 @@ impl DecodedSignature {
210210
211211 }
212212
213- pub fn encode_to_binary ( self : & Self ) -> Result < Vec < u8 > , Box < dyn Error > > {
213+ pub fn encode_to_binary ( & self ) -> Result < Vec < u8 > , Box < dyn Error > > {
214214
215215 let mut cursor = Cursor :: new ( vec ! [ ] ) ;
216216
@@ -242,7 +242,7 @@ impl DecodedSignature {
242242 cursor. write_u32 :: < LittleEndian > ( 0 ) ?; // size_minus_header - Will write later
243243
244244 let mut sorted_iterator: Vec < _ > = self . frequency_band_to_sound_peaks . iter ( ) . collect ( ) ;
245- sorted_iterator. sort_by ( |x, y| x. 0 . cmp ( & y. 0 ) ) ;
245+ sorted_iterator. sort_by ( |x, y| x. 0 . cmp ( y. 0 ) ) ;
246246
247247 for ( frequency_band, frequency_peaks) in sorted_iterator {
248248
@@ -275,7 +275,7 @@ impl DecodedSignature {
275275
276276 cursor. write_u32 :: < LittleEndian > ( 0x60030040 + * frequency_band as u32 ) ?;
277277 cursor. write_u32 :: < LittleEndian > ( peaks_buffer. len ( ) as u32 ) ?;
278- cursor. write ( & peaks_buffer) ?;
278+ cursor. write_all ( & peaks_buffer) ?;
279279 for _padding_index in 0 ..( ( 4 - peaks_buffer. len ( ) as u32 % 4 ) % 4 ) {
280280 cursor. write_u8 ( 0 ) ?;
281281 }
@@ -298,13 +298,13 @@ impl DecodedSignature {
298298 Ok ( cursor. into_inner ( ) )
299299 }
300300
301- pub fn encode_to_uri ( self : & Self ) -> Result < String , Box < dyn Error > > {
301+ pub fn encode_to_uri ( & self ) -> Result < String , Box < dyn Error > > {
302302
303303 Ok ( format ! ( "{}{}" , DATA_URI_PREFIX , base64:: encode( self . encode_to_binary( ) ?) ) )
304304
305305 }
306306
307- pub fn to_lure ( self : & Self ) -> Result < Vec < i16 > , Box < dyn Error > > {
307+ pub fn to_lure ( & self ) -> Result < Vec < i16 > , Box < dyn Error > > {
308308
309309 let mut buffer: Vec < i16 > = [ 0 ] . repeat ( ( self . number_samples as f32 / self . sample_rate_hz as f32 * 16000.0 ) as usize ) ;
310310
0 commit comments