#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# moving some particular frequency bands with minim's fft library

edited August 2015

Hello!

I hope anybody here can help me. I am trying to write an application for decoding AM-Signals and SSB-Signals on shortwave delivered by an Direct Conversion Receiver. The library which I use for analyse the soundcards frequency spectrum is minim's fft-library. I now how to get the amplitude of any frequency band an I know how to set the amplitude of any frequency band. I also know who to get the middle frequency of any frequency band, but I' am not able to move down some particular frequency bands in the sound spectrum.

This is what I tried, but it doesn't sound really good.

class InputOutputBind implements AudioSignal, AudioListener{ private float[] leftChannel ; private float[] rightChannel; InputOutputBind(int sample){ leftChannel = new float[sample]; rightChannel= new float[sample]; } // This part is implementing AudioSignal interface, see Minim reference void generate(float[] samp){ arraycopy(leftChannel,samp); } void generate(float[] left, float[] right){ arraycopy(leftChannel,left); arraycopy(rightChannel,right); } // This part is implementing AudioListener interface, see Minim reference synchronized void samples(float[] samp){
int index_band = 0; fft.forward(samp); for(int i = 0; i < 1024; i++){ if ((i >= index_lsb) && (i < index_usb)){float bandanteil = fft.getBand(i); fft1.setBand(index_band, bandanteil * 10.0); index_band += 1;} else if (i > index_usb){fft1.setBand(index_band, 0.0); index_band += 1;} } fft.inverse(samp); arraycopy(samp,leftChannel); } synchronized void samples(float[] sampL, float[] sampR){ arraycopy(sampL,leftChannel); arraycopy(sampR,rightChannel); }
}

Tagged:

• You'll get a better response if you format your code. Here's how:

http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text

• You'll get a better response if you format your code. Here's how:

Thank you, I think you are right! So this should look better.

Hello!

I hope anybody here can help me. I am trying to write an application for decoding AM-Signals and SSB-Signals on shortwave delivered by an Direct Conversion Receiver. The library which I use for analyse the soundcards frequency spectrum is minim's fft-library. I now how to get the amplitude of any frequency band an I know how to set the amplitude of any frequency band. I also know who to get the middle frequency of any frequency band, but I' am not able to move down some particular frequency bands in the sound spectrum.

`

```import ddf.minim.*;
import ddf.minim.analysis.*;
Minim            minim;
AudioInput       lineIn;
AudioOutput      lineOut;
InputOutputBind  audiosignal;
FFT fft1;
FFT fft2;
int anzahl_samples = 4096;
int samplerate = 22000;

void setup() {
size(1024, 800, P2D);
minim = new Minim(this);
lineIn = minim.getLineIn(Minim.STEREO, anzahl_samples, samplerate);
lineOut = minim.getLineOut(Minim.STEREO, anzahl_samples, samplerate);
audiosignal = new InputOutputBind(anzahl_samples);
fft1 = new FFT(anzahl_samples, samplerate);
fft2 = new FFT(anzahl_samples, samplerate);
}

void draw() {
background(0);
stroke(255);
float x = 0.0;
fft1.forward(lineIn.left);
fft2.forward(lineIn.right);
for (int i = 0; i < lineIn.bufferSize (); i++) {
float bandanteil_left = fft1.getBand(i) * 10.0;
float bandanteil_right = fft2.getBand(i) * 10.0;
line(x, (height/2.0), x, (height/2.0) - bandanteil_left);
line(x, height, x, height - bandanteil_right);
x += 0.25;
}
}

class InputOutputBind implements AudioSignal, AudioListener {
private float[] leftChannel ;
private float[] rightChannel;
InputOutputBind(int sample) {
leftChannel = new float[sample];
rightChannel= new float[sample];
}
// This part is implementing Audiosignal interface, see Minim reference
void generate(float[] samp) {
// arraycopy(leftChannel,samp);
}
void generate(float[] left, float[] right) {
float[] leftChannel_neu = new float[leftChannel.length];
float[] rightChannel_neu = new float[rightChannel.length];
for (int i = 0; i < leftChannel.length; i++) {
leftChannel_neu[i] = leftChannel[i] * 2.0;
rightChannel_neu[i] = rightChannel[i] * 2.0;
}
arraycopy(leftChannel_neu, left);
arraycopy(rightChannel_neu, right);
}
// This part is implementing AudioListener interface, see Minim reference
synchronized void samples(float[] samp) {
arraycopy(samp, leftChannel);
}
synchronized void samples(float[] sampL, float[] sampR) {
arraycopy(sampL, leftChannel);
arraycopy(sampR, rightChannel);
}
}

```

`

• You'll get a better response if you format your code. Here's how:

Thank you, I think you are right! So this should look better.

Hello!

I hope anybody here can help me. I am trying to write an application for decoding AM-Signals and SSB-Signals on shortwave delivered by an Direct Conversion Receiver. The library which I use for analyse the soundcards frequency spectrum is minim's fft-library. I now how to get the amplitude of any frequency band an I know how to set the amplitude of any frequency band. I also know who to get the middle frequency of any frequency band, but I' am not able to move down some particular frequency bands in the sound spectrum.

`

```import ddf.minim.*;
import ddf.minim.analysis.*;
Minim            minim;
AudioInput       lineIn;
AudioOutput      lineOut;
InputOutputBind  audiosignal;
FFT fft1;
FFT fft2;
int anzahl_samples = 4096;
int samplerate = 22000;

void **setup**() {
size(1024, 800, P2D);
minim = new Minim(this);
lineIn = minim.getLineIn(Minim.STEREO, anzahl_samples, samplerate);
lineOut = minim.getLineOut(Minim.STEREO, anzahl_samples, samplerate);
audiosignal = new InputOutputBind(anzahl_samples);
fft1 = new FFT(anzahl_samples, samplerate);
fft2 = new FFT(anzahl_samples, samplerate);
}

void **draw**() {
background(0);
stroke(255);
float x = 0.0;
fft1.forward(lineIn.left);
fft2.forward(lineIn.right);
for (int i = 0; i < lineIn.bufferSize (); i++) {
float bandanteil_left = fft1.getBand(i) * 10.0;
float bandanteil_right = fft2.getBand(i) * 10.0;
line(x, (height/2.0), x, (height/2.0) - bandanteil_left);
line(x, height, x, height - bandanteil_right);
x += 0.25;
}
}

class InputOutputBind implements AudioSignal, AudioListener {
private float[] leftChannel ;
private float[] rightChannel;
InputOutputBind(int sample) {
leftChannel = new float[sample];
rightChannel= new float[sample];
}
// This part is implementing Audiosignal interface, see Minim reference
void generate(float[] samp) {
// arraycopy(leftChannel,samp);
}
void generate(float[] left, float[] right) {
float[] leftChannel_neu = new float[leftChannel.length];
float[] rightChannel_neu = new float[rightChannel.length];
for (int i = 0; i < leftChannel.length; i++) {
leftChannel_neu[i] = leftChannel[i] * 2.0;
rightChannel_neu[i] = rightChannel[i] * 2.0;
}
arraycopy(leftChannel_neu, left);
arraycopy(rightChannel_neu, right);
}
// This part is implementing AudioListener interface, see Minim reference
synchronized void samples(float[] samp) {
arraycopy(samp, leftChannel);
}
synchronized void samples(float[] sampL, float[] sampR) {
arraycopy(sampL, leftChannel);
arraycopy(sampR, rightChannel);
}
}

```

`
{"ft_lang_label":"__label__en","ft_lang_prob":0.8455424,"math_prob":0.9379924,"size":3115,"snap":"2020-24-2020-29","text_gpt3_token_len":724,"char_repetition_ratio":0.12986179,"word_repetition_ratio":0.6624473,"special_character_ratio":0.2304976,"punctuation_ratio":0.13333334,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97009116,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-30T15:24:29Z\",\"WARC-Record-ID\":\"<urn:uuid:68a035c7-b3b8-4c8c-8780-3e95a1efef6a>\",\"Content-Length\":\"52337\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dd51e7a8-52cf-4873-84a2-47d541d65faf>\",\"WARC-Concurrent-To\":\"<urn:uuid:d3d46308-fa65-4bb4-841f-59125754b4dd>\",\"WARC-IP-Address\":\"45.33.79.91\",\"WARC-Target-URI\":\"https://forum.processing.org/two/discussion/comment/48636/\",\"WARC-Payload-Digest\":\"sha1:GVGQBI3NZVWMR4BI4VVOTESTB35ARZ7U\",\"WARC-Block-Digest\":\"sha1:B2QD4DTGHOO7IHIW7H6MK2ISGIWZNKJG\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347409337.38_warc_CC-MAIN-20200530133926-20200530163926-00253.warc.gz\"}"}