# HG changeset patch # User Josef 'Jeff' Sipek # Date 1618539966 14400 # Node ID daa09aecdc401557b7c59b76a6cbd6a096143b9e # Parent 2d5ae243921c41c98e9b3435cb42d2f795736a89 lib: rename phase_shift to sample_shift Instead of tracking the phase shift in signals, we should track the sample shift (i.e., delay) of the signal. The sample shift is a constant regardless of the frequency - unlike phase shift. This simplifies the tracking considerably. diff -r 2d5ae243921c -r daa09aecdc40 src/lib/signal.rs --- a/src/lib/signal.rs Wed Jun 10 12:29:27 2020 -0400 +++ b/src/lib/signal.rs Thu Apr 15 22:26:06 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Josef 'Jeff' Sipek + * Copyright (c) 2020-2021 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,8 +41,8 @@ Self: Sized { fn sample_rate(&self) -> u64; fn sample_size(&self) -> usize; + fn sample_shift(&self) -> u64; fn freq(&self) -> u64; - fn phase_shift(&self) -> u64; fn shift_freq(self, delta: i64) -> Mixer { let rate = self.sample_rate(); diff -r 2d5ae243921c -r daa09aecdc40 src/lib/signal/filesource.rs --- a/src/lib/signal/filesource.rs Wed Jun 10 12:29:27 2020 -0400 +++ b/src/lib/signal/filesource.rs Thu Apr 15 22:26:06 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Josef 'Jeff' Sipek + * Copyright (c) 2020-2021 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -59,13 +59,13 @@ U::sample_size() } + fn sample_shift(&self) -> u64 { + 0 + } + fn freq(&self) -> u64 { self.freq } - - fn phase_shift(&self) -> u64 { - 0 - } } impl Iterator for FileSourceSignal { diff -r 2d5ae243921c -r daa09aecdc40 src/lib/signal/gain.rs --- a/src/lib/signal/gain.rs Wed Jun 10 12:29:27 2020 -0400 +++ b/src/lib/signal/gain.rs Thu Apr 15 22:26:06 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Josef 'Jeff' Sipek + * Copyright (c) 2020-2021 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -49,13 +49,13 @@ std::mem::size_of::() } + fn sample_shift(&self) -> u64 { + self.lhs.sample_shift() + } + fn freq(&self) -> u64 { self.lhs.freq() } - - fn phase_shift(&self) -> u64 { - self.lhs.phase_shift() - } } impl Iterator for Gain { diff -r 2d5ae243921c -r daa09aecdc40 src/lib/signal/mixer.rs --- a/src/lib/signal/mixer.rs Wed Jun 10 12:29:27 2020 -0400 +++ b/src/lib/signal/mixer.rs Thu Apr 15 22:26:06 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Josef 'Jeff' Sipek + * Copyright (c) 2020-2021 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -56,11 +56,11 @@ std::mem::size_of::() } - fn freq(&self) -> u64 { + fn sample_shift(&self) -> u64 { panic!("TODO"); } - fn phase_shift(&self) -> u64 { + fn freq(&self) -> u64 { panic!("TODO"); } } diff -r 2d5ae243921c -r daa09aecdc40 src/lib/signal/sinusoid.rs --- a/src/lib/signal/sinusoid.rs Wed Jun 10 12:29:27 2020 -0400 +++ b/src/lib/signal/sinusoid.rs Thu Apr 15 22:26:06 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Josef 'Jeff' Sipek + * Copyright (c) 2020-2021 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -60,13 +60,13 @@ std::mem::size_of::() } + fn sample_shift(&self) -> u64 { + 0 + } + fn freq(&self) -> u64 { 0 /* the center frequency is always 0 */ } - - fn phase_shift(&self) -> u64 { - 0 - } } impl Iterator for Sinusoid {