13 releases
0.2.12alpha.0  Apr 7, 2023 

0.2.11alpha.0  Dec 19, 2022 
0.2.5alpha.0  Jun 21, 2022 
0.2.4alpha.0  Mar 14, 2022 
0.1.42alpha.0  Oct 27, 2021 
#813 in Audio
48 downloads per month
Used in 3 crates
(2 directly)
685KB
13K
SLoC
surgefxfreqshift
A frequencyshifting effect for the Surge synthesizer system.
SurgeFXFreqShift is a Rust crate providing a frequencyshifting effect, designed as a subcomponent of the Surge synthesizer system. This effect enables users to shift the frequency content of an input signal, creating unique and interesting sound transformations.
Indepth Description and Mathematical Analysis:
The frequencyshifting effect is achieved through a process called singlesideband modulation. It involves modulating the input signal with a complex exponential signal, producing upper and lower sidebands. The desired sideband is then isolated to obtain the frequencyshifted output.
Mathematically, the process can be described as follows:
 Modulation: Multiply the input signal
x(t)
with a complex exponential signale^(j * 2 * pi * f_shift * t)
, wheref_shift
is the desired frequency shift andt
is time.
y(t) = x(t) * e^(j * 2 * pi * f_shift * t)
 Isolation of the desired sideband: Apply
a filter (usually a Hilbert transform or
a similar method) to isolate the upper or lower
sideband, resulting in the frequencyshifted
output
z(t)
.
Tokens and associated mathematical ideas:

control_group
,control_type
,default_value
,max_value
,min_value
,modulateable
,moverate
,value_type
: These tokens are related to defining and configuring the parameters of the frequencyshifting effect, such as the frequency shift amount, the sideband selection, and the mix between the dry and wet signals. 
maybe_do_commented_c_process
,update
,pre_block
,FreqShift
,freqshift_smoke
,init
,suspend
,post_block
,process
: These tokens correspond to functions and structures responsible for implementing the frequencyshifting effect. They handle tasks such as initializing the effect, processing the input signal, applying the modulation and filtering operations, and managing the effect's state.
By understanding the mathematical properties and functions associated with the SurgeFXFreqShift crate, users can effectively integrate this powerful frequencyshifting effect into their Surge synthesizer system and create new and interesting sound transformations.
14> lets go back to the frequency shifter  could you describe a dozen ways we can use this effect in the context of electronic music? please describe the effect we are trying to achieve, the parameters that get us there, and how it works
Frequency shifters can be utilized in various ways to achieve unique and interesting effects in electronic music. Here are twelve examples of how a frequency shifter can be used, along with the desired effect, parameters, and an explanation of how it works:

Subtle detuning: Add a touch of detuning to thicken and enhance the sound of synth leads or pads. Set the frequency shift to a low value (e.g., 110 Hz) and mix with the dry signal. This creates a subtle beating effect due to phase differences, enriching the overall sound.

Beat frequency oscillation: Apply a frequency shift to a drum loop or percussive sound to create rhythmic patterns or emphasize specific elements. Adjust the frequency shift to match the desired beat frequency and set the mix to blend the effect.

Stereo widening: Apply a frequency shifter to create a stereo widening effect. Use a small frequency shift value on one channel (e.g., left) and a slightly different value on the other channel (e.g., right). This creates phase differences between the channels, enhancing the stereo image.

Alienlike vocal transformations: Apply a frequency shifter to vocals to create otherworldly, alienlike effects. Set the frequency shift to a moderate value (e.g., 100500 Hz) and adjust the mix to taste. This changes the harmonic structure of the vocals, producing an unusual and unique effect.

Bass enhancement: Use a frequency shifter to add upper harmonics to bass sounds, making them more perceptible on smaller speakers. Set a moderate frequency shift value (e.g., 50100 Hz) and blend it with the dry signal to create additional harmonics without drastically altering the original bass sound.

Psychedelic effects: Apply a frequency shifter with a high frequency shift value (e.g., 5002000 Hz) to create psychedelic, otherworldly soundscapes. Experiment with various modulation rates and depths to achieve different textures and movement in the sound.

Ringing modulator: Use a frequency shifter as a ringing modulator by setting the frequency shift to a musically relevant interval (e.g., 100, 200, or 300 Hz). This creates a metallic, belllike effect that can be used to add character to synth sounds, pads, or percussion.

Formant shifting: Apply a frequency shifter to vocal samples or synthesized vowels to alter the formant structure without changing the pitch. Adjust the frequency shift and mix parameters to achieve the desired formant shift while maintaining the original pitch.

Creating dissonance: Use a frequency shifter to create dissonance in harmonic or melodic material. Apply a small, nonmusical frequency shift (e.g., 520 Hz) to introduce subtle beating and phase cancellation, creating a sense of tension and unease.

Sound design for SFX: Apply a frequency shifter to create unique sound effects for electronic music productions. Experiment with various frequency shift values, modulation rates, and depths to generate interesting and evolving textures.

Layering with reverb: Combine a frequency shifter with a reverb effect to create lush, evolving soundscapes. Apply the frequency shifter before or after the reverb in the signal chain to explore different textures and harmonic interactions.

Resonance emphasis: Use a frequency shifter to emphasize specific resonant frequencies in a sound. Set the frequency shift to match the resonant frequency and adjust the mix to enhance the resonance.
These are just a few examples of how a frequency shifter can be used creatively in electronic music. Experiment with different frequency shift values, modulation rates, and
15> which input material is the most fruitfully frequency shifted? what can come downstream from this effect in the pipeline? what can come in parallel?
Frequency shifters can produce interesting effects with a variety of input materials, but some sources tend to yield more fruitful results:

Harmonicrich sounds: Synth leads, pads, and complex waveforms with rich harmonic content tend to produce more noticeable and interesting effects when frequency shifted, as the process alters the harmonic structure of the sound.

Percussive sounds and drum loops: Frequency shifting can create interesting rhythmic patterns, emphasize specific elements, or add texture to drum loops and percussive sounds.

Vocals and speech: Vocal samples, spoken word, or synthesized vowels can produce unique and otherworldly effects when frequency shifted, altering the formant structure or creating alienlike transformations.
In the processing pipeline, various effects can be used downstream from a frequency shifter to further shape the sound:

Filters: Lowpass, highpass, or bandpass filters can be used to control the frequency content of the shifted signal or emphasize specific frequencies.

Distortion/Saturation: Applying distortion or saturation after frequency shifting can add warmth, harmonics, and character to the shifted sound.

Delay and Reverb: Adding delay or reverb can create depth and space in the frequencyshifted sound, resulting in lush, evolving soundscapes or psychedelic effects.

Chorus, Phaser, or Flanger: Modulation effects can be applied after frequency shifting to introduce additional movement and stereo width to the sound.

Dynamics processing: Compressors, limiters, or transient shapers can be used to control the dynamics of the frequencyshifted signal and help it sit better in the mix.
In parallel processing, you can combine the frequencyshifted signal with other effects or a dry version of the input signal:

Parallel compression: Apply compression to the frequencyshifted signal and blend it with the dry signal to maintain the original dynamics while adding the shifted effect.

Parallel distortion: Distort the frequencyshifted signal and mix it with the dry signal to add harmonic richness without drastically changing the original sound.

Parallel filtering: Apply different filters to the frequencyshifted and dry signals, and then mix them together to create complex spectral shapes or emphasize specific frequency ranges.

Parallel modulation effects: Apply chorus, phaser, or flanger effects to the frequencyshifted signal and blend with the dry signal to create a more complex, evolving texture.
By combining a frequency shifter with various downstream or parallel effects, you can create a wide range of unique and expressive sounds that can be used in electronic music production.
16> could you teach me how the subcomponents of this effect work from a mathematical perspective? what about from the perspective of physics and engineering?
Sure! A frequency shifter works by altering the frequencies of the input signal, creating unique sound transformations. It operates using a process called singlesideband modulation. Let's break down the subcomponents of the effect from mathematical, physics, and engineering perspectives.
Mathematical Perspective
 Modulation: Frequency shifting is achieved
by multiplying the input signal
x(t)
with a complex exponential signal `e^(j * 2 * pi f_shift * t)
, where
f_shiftis the desired frequency shift,
jis the imaginary unit, and
t` is time. This multiplication results in the sum and difference of the input frequencies, generating upper and lower sidebands.
 f_shift * t)
y(t) = x(t) * e^(j * 2 * pi * f_shift * t)
 Isolation of the desired sideband: To
obtain the frequencyshifted output, a filter
(usually a Hilbert transform or a similar
method) is applied to isolate either the upper
or lower sideband. The filtered signal is then
mixed back with the original signal or used on
its own as the frequencyshifted output
z(t)
.
Physics and Engineering Perspective

Complex exponential signal generation: To generate the complex exponential signal, a local oscillator is used, which produces a sinusoidal signal with a frequency equal to the desired frequency shift. The sine and cosine components of this signal represent the real and imaginary parts of the complex exponential signal.

Hilbert transform: The Hilbert transform is a linear, timeinvariant operation that shifts the phase of each frequency component of the input signal by +90 degrees for the upper sideband or 90 degrees for the lower sideband. In digital systems, this is usually accomplished using a Fast Fourier Transform (FFT), phase manipulation, and an inverse Fast Fourier Transform (iFFT).

Sideband filtering: To isolate the desired sideband, the modulated signal is passed through a filter that removes the unwanted sideband. In the case of the Hilbert transform, this filtering is inherently accomplished by the phase manipulation.

Mixing or demodulation: The isolated sideband is then mixed back with the original signal or used independently as the frequencyshifted output. This can be done using various techniques, such as ring modulation, vector rotation, or phase vocoding.
By understanding the mathematics, physics, and engineering principles underlying the frequency shifter effect, you can better appreciate how it works and manipulate its subcomponents to create a wide range of unique sound transformations in electronic music.
Dependencies
~9–17MB
~327K SLoC