# Frequency Inversion

Started by August 28, 2006
```I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
frequency band that i can use is below 4000Hz (8000/2). I would like to
have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
3kHz and 3kHz will go to 300Hz and the in-between are flip).

I tried many methods to do it but fails.

1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
there's distortion.

2) Like a SSB modulation, to move the lower band in the (300 to 3k)
region. But it requires a Hilbert transform. There are many approximations
of Hilbert transform like using remez function in matlab and other FIR or
IIR filters. But in SSB, if the phase response of those filters are not
out-of-phase 90 degree difference, the upper band components cannot be
cancelled and the result is not good.

So can anyone help me to figure out those problem or have any other good
scrambling methods or algorithms that are easy to implement in DSP.

```
```bachbeethoven200 wrote:
> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
> I tried many methods to do it but fails.
>
> 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> there's distortion.
>
If you are going to mix one signal with another to get a desired
output, you will need to put a filter on your output to remove the
unwanted signal component.  Recall that cosA * cosB = cos( A + B ) +
cos( A - B ).  So if you only want the lower component you would need a
lowpass filter with the proper cutoff frequency.

> 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> region. But it requires a Hilbert transform. There are many approximations
> of Hilbert transform like using remez function in matlab and other FIR or
> IIR filters. But in SSB, if the phase response of those filters are not
> out-of-phase 90 degree difference, the upper band components cannot be
> cancelled and the result is not good.
>
> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.

```
```On Mon, 28 Aug 2006 05:24:19 -0500, "bachbeethoven200"
<beethoven@wyk.edu.hk> wrote:

>I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
>frequency band that i can use is below 4000Hz (8000/2). I would like to
>have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
>3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
>I tried many methods to do it but fails.
>
>1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
>that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
>there's distortion.
>
>2) Like a SSB modulation, to move the lower band in the (300 to 3k)
>region. But it requires a Hilbert transform. There are many approximations
>of Hilbert transform like using remez function in matlab and other FIR or
>IIR filters. But in SSB, if the phase response of those filters are not
>out-of-phase 90 degree difference, the upper band components cannot be
>cancelled and the result is not good.
>
>So can anyone help me to figure out those problem or have any other good
>scrambling methods or algorithms that are easy to implement in DSP.

Hi bachbeethoven,

I can't think of a simple way to
invert your spectrum that doesn't require
quadrature processing (complex-valued samples)
or frequency-domain processing (performing
forward and inverse DFTs).

However, you might take your original
real-valued time sequence and negate (change
the sign) of alternate samples.  That will give you
an inverted spectrum positioned from 1000 -to- 3700 Hz.

That's not exactly what you asked for, but maybe
it could somehow be used in your application.

Good Luck,
[-Rick-]

```
```
bachbeethoven200 wrote:

> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
> I tried many methods to do it but fails.
>

All you have to do is invert the sign of the every second sample.

> 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> there's distortion.
>
> 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> region. But it requires a Hilbert transform. There are many approximations
> of Hilbert transform like using remez function in matlab and other FIR or
> IIR filters. But in SSB, if the phase response of those filters are not
> out-of-phase 90 degree difference, the upper band components cannot be
> cancelled and the result is not good.

:))))
In many cases, extra knowledge is only harmfull.

> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.

Take any voice compression algorithm (like G.723.1 for example) and
apply AES to the digital data. Keep in mind that the development of such
algorithms is a controlled issue in most of the countries.

DSP and Mixed Signal Design Consultant

http://www.abvolt.com

```
```"bachbeethoven200" <beethoven@wyk.edu.hk> writes:

> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
> I tried many methods to do it but fails.
>
> 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> there's distortion.
>
> 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> region. But it requires a Hilbert transform. There are many approximations
> of Hilbert transform like using remez function in matlab and other FIR or
> IIR filters. But in SSB, if the phase response of those filters are not
> out-of-phase 90 degree difference, the upper band components cannot be
> cancelled and the result is not good.
>
> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.

I don't mean to frustrate you (I know I am sometimes frustrated when
people ask me these types of questions), but perhaps it would help to
know WHY you want to perform this operation. Perhaps there is another
approach to your problem altogether that is simpler.
--
%  Randy Yates                  % "Though you ride on the wheels of tomorrow,
%% Fuquay-Varina, NC            %  you still wander the fields of your
%%% 919-577-9882                %  sorrow."
%%%% <yates@ieee.org>           % '21st Century Man', *Time*, ELO
```
```bachbeethoven200 wrote:
> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
> I tried many methods to do it but fails.
>
> 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> there's distortion.
>
> 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> region. But it requires a Hilbert transform. There are many approximations
> of Hilbert transform like using remez function in matlab and other FIR or
> IIR filters. But in SSB, if the phase response of those filters are not
> out-of-phase 90 degree difference, the upper band components cannot be
> cancelled and the result is not good.
>
> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.
>
I think that one way or another you're going to be implementing a
Hilbert transform, or at least replicating the amount of delay and
computational complexity of using it.

Are you band-limiting your Hilbert transform?  A true Hilbert transform
with a response that goes down to DC has an infinite height in the time
domain, which can be a bit rough to implement with real components.  But
if you cascade a Hilbert transform with a high-pass filter the response
is large, but not infinite.

You may want to consider, instead of using a delayed version of your
signal and a hilbert transformed version, to use one version shifted +45
degrees, and another shifted -45.  If nothing else this will ease the
height of the peak by a factor of 2.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```Vladimir,

Reading a little into the original post I would guess that he is trying
to preserve the audio bandwidth to put the inverted audio through a
bandlimited channel.  If you have a spectrum from 300-3000 Hz (8Ksps)
and flip every other sample as suggested, the inverted spectrum covers
1000-3700 Hz.  Passing this through a channel that cuts off at 3000 Hz
limits the inverted channel to 1000-3000 Hz.  When this is inverted,
the original frequency content is limited to 1000-3000 Hz which makes
for some really bad audio. So inverting the sign of every other sample
is not the way to go.

Dirk Bell
DSP Consultant

> bachbeethoven200 wrote:
>
> > I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> > frequency band that i can use is below 4000Hz (8000/2). I would like to
> > have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> > 3kHz and 3kHz will go to 300Hz and the in-between are flip).
> >
> > I tried many methods to do it but fails.
> >
>
> All you have to do is invert the sign of the every second sample.
>
>
> > 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> > that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> > there's distortion.
> >
> > 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> > region. But it requires a Hilbert transform. There are many approximations
> > of Hilbert transform like using remez function in matlab and other FIR or
> > IIR filters. But in SSB, if the phase response of those filters are not
> > out-of-phase 90 degree difference, the upper band components cannot be
> > cancelled and the result is not good.
>
> :))))
> In many cases, extra knowledge is only harmfull.
>
>
> > So can anyone help me to figure out those problem or have any other good
> > scrambling methods or algorithms that are easy to implement in DSP.
>
> Take any voice compression algorithm (like G.723.1 for example) and
> apply AES to the digital data. Keep in mind that the development of such
> algorithms is a controlled issue in most of the countries.
>
>
>
> DSP and Mixed Signal Design Consultant
>
> http://www.abvolt.com

```
```Musicman,

Stick with the SSB approach.  Process should be complex mix, lowpass
filter, complex mix, take real part to get the audio inverted around
1650 Hz (last 2 steps can be combined for simplicity).  Work through
this on paper to make sure everything is going where you expect it to
go spectrally, and with a little more work you will see how to invert
it.  The quality can be very good, I have done it this way.

Dirk Bell
DSP Consultant

bachbeethoven200 wrote:
> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
>
> I tried many methods to do it but fails.
>
> 1) Like a frequency shifting, I can shift the (-3k to 300) to (300 and 3k)
> that means multipy a cosine of 3300Hz, but due to the 8000 sampling rate,
> there's distortion.
>
> 2) Like a SSB modulation, to move the lower band in the (300 to 3k)
> region. But it requires a Hilbert transform. There are many approximations
> of Hilbert transform like using remez function in matlab and other FIR or
> IIR filters. But in SSB, if the phase response of those filters are not
> out-of-phase 90 degree difference, the upper band components cannot be
> cancelled and the result is not good.
>
> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.

```
```bachbeethoven200 wrote:
> I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> frequency band that i can use is below 4000Hz (8000/2). I would like to
> have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> 3kHz and 3kHz will go to 300Hz and the in-between are flip).
...
> So can anyone help me to figure out those problem or have any other good
> scrambling methods or algorithms that are easy to implement in DSP.

I always thought that scrampling signals that way (frequency inversion)
or by permuting frequency bands was only used for analog signals. For
digital signals, it would seem that standard data encryption is a) much
more secure and b) simpler to implement.

VLV mentioned AES, which would also be my algorithm of choice. There is
source code out there, just look.

Regards,
Andor

```
```Andor,

Even if the signal is digitized for processing (which may be required
for the scrambler implementation chosen) , the signal may have to be
converted back to analog to go through a low bandwidth analog channel
(analog telephone channel, analog radio channel).  I ran into this
general type of frequency inversion in production in 2002.

Dirk Bell
DSP Consultant

Andor wrote:
> bachbeethoven200 wrote:
> > I have an audial signal of sampling rate 8000Hz (16 bits per sample) so the
> > frequency band that i can use is below 4000Hz (8000/2). I would like to
> > have a frequency inversion of 300Hz to 3kHz that means (300Hz will go to
> > 3kHz and 3kHz will go to 300Hz and the in-between are flip).
> ...
> > So can anyone help me to figure out those problem or have any other good
> > scrambling methods or algorithms that are easy to implement in DSP.
>
> I always thought that scrampling signals that way (frequency inversion)
> or by permuting frequency bands was only used for analog signals. For
> digital signals, it would seem that standard data encryption is a) much
> more secure and b) simpler to implement.
>
> VLV mentioned AES, which would also be my algorithm of choice. There is
> source code out there, just look.
>
> Regards,
> Andor

```