Old 01-16-2014, 02:44 PM   #1
Obe
Human being with feelings
 
Obe's Avatar
 
Join Date: Feb 2013
Location: France
Posts: 18
Default Spectral Inversion

I haven't seen this simple algorithm in the forum or in the stash so here it is : Spectral Inversion.

More precisely, it mirrors the frequency, the miror being the Nysquist Frequency (that is to say the sample frequency divided by 2, most of the time : 22050Hz).

A sine at 440 Hz, is now a sine at 22050 - 440 = 21610 Hz (inaudible, I know...)

So beware the dreadful DSP part, here comes the code :

Code:
desc:SpectralInversion

@init
isSecondSample = 0;

@sample
  isSecondSample ? 
  (
  spl0 = -spl0;
  spl1 = -spl1;
  isSecondSample = 0;
  )
  :
  (
  isSecondSample = 1;
  );
Quite simple, isn't it ? The idea is to swap the sign of every second sample. And thanks to the vodoo of the mathematic in the Zplane, the frequencies are no "inversed".

Now, the bad news. It isn't very musical. Indeed, all the tonal content of the music is lost in the process (except G note (at 44100Hz))... but it is fun to watch with a frequency analyser (like gfxAnalyser for instance or even better schwa schope ) !


As an example, I have used as a "fade out FX", on one of my composition (here is the link : https://soundcloud.com/matth-1-1/scintillation).
Obe is offline   Reply With Quote
Old 01-16-2014, 03:17 PM   #2
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
Default

As I stared blankly at it, I wondered if it could be done without a conditional.

Code:
desc:SpectralInversion

@init
isSecondSample = 1;

@sample

spl0 = spl0 * isSecondSample;
spl1 = spl1 * isSecondSample;

isSecondSample *= -1;
SaulT is offline   Reply With Quote
Old 08-27-2014, 12:01 PM   #3
DJ Saint-Hubert
Human being with feelings
 
Join Date: Jan 2013
Posts: 257
Default

I've actually used this a couple of times! Except I do stuff to the audio and then flip it back so to speak. Am I right that using a waveshaper/saturation/distortion on the inverted signal will cause subharmonics instead of harmonics when flipped back? I know I hear /some/ difference and it feels more in my gut or whatever. Also I'm pretty sure if you EQ in inverted mode you can equalize where the EQ normally wouldn't allow? (< 20 hz) I don't hear any stability issues if it is in fact centered at 10, 5 hz or whatever. Would this cause desirable/undesirable phasing too? Only issue so far is you can't oversample in inverted mode . Well you can but it just adds some noisy artifacts to your song and makes it unusable
DJ Saint-Hubert is offline   Reply With Quote
Old 08-27-2014, 01:48 PM   #4
Smashed Transistors
Human being with feelings
 
Smashed Transistors's Avatar
 
Join Date: Jul 2014
Location: Là bas les huîtres (FR)
Posts: 424
Default

To me it is a form of extreme ring modulation (ring modulation at half the sample rate).
So it is good for generating inharmonic sounds.

DJ Saint-Hubert, if you distort in the mirror, you add harmonics that are aliased, when they are mirrored back, they will be inharmonic, not subharmonics.

To produce subharmonics you'll need a method that multiplies/divides frequencies (Pitch shifters).

Ring modulation (and other voluntary S&H and aliasing) allows frequency mirroring and frequency translations... and can only produce inharmonics (excepted for s&h / ring frequency related to the fundamental of the input signal).

PS i love s&h and ring mod... i've written a nasty midi-controlled-effect.. will upload it someday
__________________
JSFX plugins and synths. See you here and there: SoundCloud, Youtube, Google Play...
Smashed Transistors is offline   Reply With Quote
Old 08-27-2014, 02:07 PM   #5
DJ Saint-Hubert
Human being with feelings
 
Join Date: Jan 2013
Posts: 257
Default

Quote:
Originally Posted by Smashed Transistors View Post
To me it is a form of extreme ring modulation (ring modulation at half the sample rate).
So it is good for generating inharmonic sounds.

DJ Saint-Hubert, if you distort in the mirror, you add harmonics that are aliased, when they are mirrored back, they will be inharmonic, not subharmonics.

To produce subharmonics you'll need a method that multiplies/divides frequencies (Pitch shifters).

Ring modulation (and other voluntary S&H and aliasing) allows frequency mirroring and frequency translations... and can only produce inharmonics (excepted for s&h / ring frequency related to the fundamental of the input signal).

PS i love s&h and ring mod... i've written a nasty midi-controlled-effect.. will upload it someday

interesting
DJ Saint-Hubert is offline   Reply With Quote
Old 08-28-2014, 06:43 PM   #6
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

I didn't try this thing, but I did have a bunch of fun last night "mirroring" things with a ring modulator. Put a high pass before and a low pass after with all of the frequencies somewhere in the middle of the audio band and you get almost nothing but the difference signals. Do the opposite - low pass>ring mod>high pass - and you get mostly just the sum frequencies. Do both parallel to each other, and mix the results together and you get some good fun! Added a little distortion and delay for fun, and turned this into this.

It wouldn't take a whole lot to make a JS that will do that. The filters need to be kind of steep, but it might be cool.
ashcat_lt is online now   Reply With Quote
Old 08-29-2014, 03:16 AM   #7
Smashed Transistors
Human being with feelings
 
Smashed Transistors's Avatar
 
Join Date: Jul 2014
Location: Là bas les huîtres (FR)
Posts: 424
Default

Quote:
Originally Posted by ashcat_lt View Post
I didn't try this thing, but I did have a bunch of fun last night "mirroring" things with a ring modulator. Put a high pass before and a low pass after with all of the frequencies somewhere in the middle of the audio band and you get almost nothing but the difference signals. Do the opposite - low pass>ring mod>high pass - and you get mostly just the sum frequencies. Do both parallel to each other, and mix the results together and you get some good fun! Added a little distortion and delay for fun, and turned this into this.

It wouldn't take a whole lot to make a JS that will do that. The filters need to be kind of steep, but it might be cool.
Maybe you can use the Hilbert Transform too.
__________________
JSFX plugins and synths. See you here and there: SoundCloud, Youtube, Google Play...
Smashed Transistors is offline   Reply With Quote
Old 08-29-2014, 12:45 PM   #8
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

Quote:
Originally Posted by Smashed Transistors View Post
Maybe you can use the Hilbert Transform too.
Errr...that's a bit beyond my pay grade. Calculus in JS? Don't sound like fun to me!
ashcat_lt is online now   Reply With Quote
Old 09-01-2014, 03:07 PM   #9
Smashed Transistors
Human being with feelings
 
Smashed Transistors's Avatar
 
Join Date: Jul 2014
Location: Là bas les huîtres (FR)
Posts: 424
Default

It's just a FIR filter that shifts phases 90°. Along with a delay line it provides you with a "analytic signal". This can be used for single sideband modulations... it is quite the same sort of things you do with your high pass and low pass filters.
__________________
JSFX plugins and synths. See you here and there: SoundCloud, Youtube, Google Play...
Smashed Transistors is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.