Skip to content

Commit

Permalink
self: &mut self -> &mut self; self: &Self -> &self
Browse files Browse the repository at this point in the history
  • Loading branch information
dotX12 committed Jan 28, 2024
1 parent dbb4f47 commit efbb397
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/fingerprinting/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl SignatureGenerator {
this.signature
}

fn do_fft(self: &mut Self, s16_mono_16khz_buffer: &[i16]) {
fn do_fft(&mut self, s16_mono_16khz_buffer: &[i16]) {

// Copy the 128 input s16le samples to the local ring buffer

Expand Down Expand Up @@ -150,7 +150,7 @@ impl SignatureGenerator {
self.fft_outputs_index &= 255;
}

fn do_peak_spreading(self: &mut Self) {
fn do_peak_spreading(&mut self) {
let real_fft_results = &self.fft_outputs[((self.fft_outputs_index as i32 - 1) & 255) as usize];

let spread_fft_results = &mut self.spread_fft_outputs[self.spread_fft_outputs_index];
Expand Down Expand Up @@ -182,7 +182,7 @@ impl SignatureGenerator {
self.spread_fft_outputs_index &= 255;
}

fn do_peak_recognition(self: &mut Self) {
fn do_peak_recognition(&mut self) {

// Note: when substracting an array index, casting to signed is needed
// to avoid underflow panics at runtime.
Expand Down
12 changes: 6 additions & 6 deletions src/fingerprinting/signature_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ impl FrequencyPeak {
/// rate, 1024 useful bins and the multiplication by 64 made before
/// storing the information

pub fn get_frequency_hz(self: &Self) -> f32 {
pub fn get_frequency_hz(&self) -> f32 {

self.corrected_peak_frequency_bin as f32 * (self.sample_rate_hz as f32 / 2.0 / 1024.0 / 64.0)

}

/// Not sure about this calculation but gives small enough numbers

pub fn get_amplitude_pcm(self: &Self) -> f32 {
pub fn get_amplitude_pcm(&self) -> f32 {

(((self.peak_magnitude as f32 - 6144.0) / 1477.3).exp() * ((1 << 17) as f32) / 2.0).sqrt() / 1024.0

Expand All @@ -38,7 +38,7 @@ impl FrequencyPeak {
/// Assume that new FFT bins are emitted every 128 samples, on a
/// standard 16 KHz sample rate basis.

pub fn get_seconds(self: &Self) -> f32 {
pub fn get_seconds(&self) -> f32 {

(self.fft_pass_number as f32 * 128.0) / self.sample_rate_hz as f32

Expand Down Expand Up @@ -210,7 +210,7 @@ impl DecodedSignature {

}

pub fn encode_to_binary(self: &Self) -> Result<Vec<u8>, Box<dyn Error>> {
pub fn encode_to_binary(&self) -> Result<Vec<u8>, Box<dyn Error>> {

let mut cursor = Cursor::new(vec![]);

Expand Down Expand Up @@ -298,13 +298,13 @@ impl DecodedSignature {
Ok(cursor.into_inner())
}

pub fn encode_to_uri(self: &Self) -> Result<String, Box<dyn Error>> {
pub fn encode_to_uri(&self) -> Result<String, Box<dyn Error>> {

Ok(format!("{}{}", DATA_URI_PREFIX, base64::encode(self.encode_to_binary()?)))

}

pub fn to_lure(self: &Self) -> Result<Vec<i16>, Box<dyn Error>> {
pub fn to_lure(&self) -> Result<Vec<i16>, Box<dyn Error>> {

let mut buffer: Vec<i16> = [0].repeat((self.number_samples as f32 / self.sample_rate_hz as f32 * 16000.0) as usize);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/song_history_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl SongRecordInterface for FavoritesInterface {
}

impl FavoritesInterface {
pub fn get_is_favorite(self: &Self) -> &HashSet<Song> {
pub fn get_is_favorite(&self) -> &HashSet<Song> {
&self.is_favorite
}
}
4 changes: 2 additions & 2 deletions src/utils/csv_song_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ pub struct Song {
}

pub trait IsSong {
fn get_song(self: Self) -> Song;
fn get_song(self) -> Song;
}

impl IsSong for SongHistoryRecord {
fn get_song(self: Self) -> Song {
fn get_song(self) -> Song {
return Song {
song_name: self.song_name,
album: self.album,
Expand Down

0 comments on commit efbb397

Please sign in to comment.