resonant bypass filter

Status
Not open for further replies.

voltaire

New member
Hi there,

I'm working on an audiovisual installation; something about icebergs and the sound of the wind on them. I need to use teensy as it is interactive, to create the sound. Unfortunately, I'm not really used to create sounds with the Audi Library. So I may need you help. I've made a patch max of the idea of the sound I'm trying to create... (quite easy, in fact, as you can see).

The main idea is to multiply a 800 Hz sinusoidal oscillator with another signal composed from a random signal ( rand~ 225 ) or a pink signal sent to a resonant bypass filter ( reson~ 1. 100 100 ). See the screenshot of the patch Max bellow, and you can listen to the result here: https://www.dropbox.com/s/gsc85m8nvltjh5b/snd_extract_01.aiff?dl=0

Capture d’écran 2017-08-05 à 16.31.40.png

Is there an equivalent to the resonant bypass filter in the Teensy Audio Library ?

Thank you in advance for your help !

Bellow, the code of the max patch, if needed.

Code:
<pre><code>
----------begin_max5_patcher----------
440.3ocyT00SCCBE841eEDdzTWJztOz272gwXvVbhoCZ.5beD2ucgKsyM2zM
cKY9PogKG3bOGtWVFGgeRMiavnaQ2ihhVFGEAg7AhZmGgmvlUTwL.LLeQIqX
ENIrTMyV7hPN9QMuvFNl7g8RSPzQo9e486FQOztEQIbNpmd8ZR2wHalnZrUb
KvQZaTicdEG.uANgrCF0G683X+PxQl8R9aNh6NNKeFjzXM2njqPjdHRZp+6G
zGIi30zng85mfHjAfZy1PfOqjViXAj4D2B6pa5M3MvJYSBp7NsfUseKgzFMD
xNulGRFrQLV51zZxOfmke97rqNbQ.IXRYT+Hk9cdDcedTV5kxiNm0ULY4Jmx
6e35ov3.ne42ZUjKkUQNeVUw7hJ9Jzner2KTV0ZUi9KVE8+PUErGbkP90mdA
I6ius+YTM5hNd6ZNPep6RtwJjLqPI2.jqp.QViQoK4Z3008dmc1YNcWlImDy
9GMOHyP54D8ooQxQvTW5bZLQOVMsMSgBHVc8Tt1zhFHw0p8pBL6gIvTgLLMC
lp4SEc3ygHLsqGy5ZvZzgh2YCxwgspbWaxFQ6Mmi42i+.n6AeGN
-----------end_max5_patcher-----------
</code></pre>
 
Last edited:
Maybe like this?

sc.png

Don't forget to add lines in setup() to configure the sine frequency, filter frequency & resonance, and mixer gains. The right-side panel has the details as you click on each object.
 
Is there an equivalent to the resonant bypass filter in the Teensy Audio Library ?

Yes, this:

https://www.pjrc.com/teensy/gui/?info=AudioFilterStateVariable

You can even use another signal to modulate its frequency (but not the amount of resonance). The Q value is limited to 5.0. Not sure if that's enough for your application, but probably worth a try.

The biquad filter might also be a possibility. Check out it's setBandpass() function.

https://www.pjrc.com/teensy/gui/?info=AudioFilterBiquad
 
Hi Paul,

Thank you so much for your answer. Well, I tried both filter, but I didn't get a good result with them... but maybe, I'm going wrong with them ?

If you listen to the sound I'm trying to get (or approaching), it's "round" and "wailing" with this feeling of "multiple voices singing together".

I'm quite sure it's coming from the resonant effect used in the Max/MSP filter: if you look at the documentation, it seems that there is a loop inside the filter, following this equation:

reson~ implements the following filter equation:

y[n] = a0 * (x[n] - r * x[n-2]) + b1 * y[n-1] + b2 * y[n-2]
where r, b1, and b2 are parameters calculated from the input center frequency fc and Q.

Q = fc/bandwidth.

Inputs can be floats or signals.

84CB7434-358A-42D6-B2FB-C499D41C471A.png

I also tried a different approach, combining two sine wave, with two biquad filter and a filter + reverb. I have something, but not as "clean" or "round" as I want...

Capture d’écran 2017-08-10 à 09.51.03.jpg

If you know a way to get closer to this, it would be really helpful. Maybe the best solution would be to build from scratch a filter, but I don't have any skills for that.

Thanks again for your help !
 
Hi Paul,

Thank you so much for your answer. Well, I tried both filter, but I didn't get a good result with them... but maybe, I'm going wrong with them ?


I'm quite sure it's coming from the resonant effect used in the Max/MSP filter: if you look at the documentation, it seems that there is a loop inside the filter, following this equation:

The reson filter shown is a special version of a biquad bandpass filter.
what I however not understand are the parameters of reson, in particular the third parameter. from docu this thould be a Q value of 100, which for me means making a BP filter at 100 Hz (2nd parameter) with 1 Hz bandwidth.
IMO, this is nearly impossible for audio library that runs at a sampling frequency of 44.1kHz and uses 16 bit arithmetic.

you may have to look into other methods to generate the sound effect you are interested in.
 
Hi WMXZ,

Thank you for your answer :) Crystal clear. I need to dig more to find another way to approach this sound - if you have any idea, feel free ! Or even, create a totally different "windy" sound, based on the solution Paul just s

Thanks for your help !
 
Hi WMXZ,

Thank you for your answer :) Crystal clear. I need to dig more to find another way to approach this sound - if you have any idea, feel free ! Or even, create a totally different "windy" sound, based on the solution Paul just s

Thanks for your help !

maybe you try the attached example
it contains a floating point biquad
you can switch from float to q15 version (the later is not good) and play with frequencies, amplitudes, mixing etc.
I used an audio card to listen, but you could use alse usb-audio to listen from PC

Edit: error: relace
Code:
      biquad1.setLowpass(ii, 800.0f, 10.0f);
by
Code:
      biquad1.setBandpass(ii, 700.0f, 10.0f);

to be consistent with floating point (now q15 sounds similar to float version)

In principle you do not need the 800 Hz tone only the noise that passes through biquad.
Also, mixer is additive not multiplicative.
Maybe multiple noises and biquads could generate different windy effects
 

Attachments

  • TestReson.zip
    5.3 KB · Views: 142
Last edited:
Now without float biquads
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthNoiseWhite     noise1;         //xy=165,99
AudioSynthNoiseWhite     noise2;         //xy=173,205
AudioFilterBiquad        biquad1;        //xy=352,98
AudioFilterBiquad        biquad2;        //xy=352,203
AudioMixer4              mixer1;         //xy=568,152
AudioOutputI2S           i2s1;           //xy=749,154
AudioConnection          patchCord1(noise1, biquad1);
AudioConnection          patchCord2(noise2, biquad2);
AudioConnection          patchCord3(biquad1, 0, mixer1, 0);
AudioConnection          patchCord4(biquad2, 0, mixer1, 1);
AudioConnection          patchCord5(mixer1, 0, i2s1, 0);
AudioConnection          patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=258,368
// GUItool: end automatically generated code


void setup() {
  // Audio requires memory to work.
  AudioMemory(16);

  AudioNoInterrupts();

    for(int ii=0;ii<4;ii++)
    {
      biquad1.setBandpass(ii, 400.0f, 5.0f);
      biquad2.setBandpass(ii, 800.0f, 10.0f);
    }
  //
  noise1.amplitude(0.8);
  noise2.amplitude(0.8);

  mixer1.gain(0,1.0);
  mixer1.gain(1,1.0);
  mixer1.gain(2,0.0);
  mixer1.gain(3,0.0);

  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  AudioInterrupts();
}


void loop() {
}

While the OP has 1 biquad with a Q of 100
using 4 biquads allows the reduction of Q per section.
Also modelling the resonance driven directly with noise allows higher bandpass biquads.
IMO, one can simulate any wind-driven soundscape with such a system
For very low Q maybe ping noise is better than white noise
 
Or if you really want
mixture of tonal and fuzzy noise
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

#include "filter_biquad_f.h"

// GUItool: begin automatically generated code
AudioSynthNoiseWhite     noise1;         //xy=165,99
AudioSynthNoiseWhite     noise2;         //xy=173,205
AudioSynthWaveformSine   sine1;          //xy=175,298
AudioSynthNoiseWhite     noise3;         //xy=176,390
AudioFilterBiquad_F        biquad3;        //xy=342,389
AudioFilterBiquad        biquad1;        //xy=352,98
AudioFilterBiquad        biquad2;        //xy=352,203
AudioEffectMultiply      multiply1;      //xy=366,291
AudioMixer4              mixer1;         //xy=568,152
AudioOutputI2S           i2s1;           //xy=749,154
AudioConnection          patchCord1(noise1, biquad1);
AudioConnection          patchCord2(noise2, biquad2);
AudioConnection          patchCord3(sine1, 0, multiply1, 0);
AudioConnection          patchCord4(noise3, biquad3);
AudioConnection          patchCord5(biquad3, 0, multiply1, 1);
AudioConnection          patchCord6(biquad1, 0, mixer1, 0);
AudioConnection          patchCord7(biquad2, 0, mixer1, 1);
AudioConnection          patchCord8(multiply1, 0, mixer1, 2);
AudioConnection          patchCord9(mixer1, 0, i2s1, 0);
AudioConnection          patchCord10(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=620,442
// GUItool: end automatically generated code

float Coeff[4*5];

void setup() {
  // Audio requires memory to work.
  AudioMemory(16);

  AudioNoInterrupts();

    for(int ii=0;ii<4;ii++)
    {
      biquad1.setBandpass(ii, 400.0f, 5.0f);
      biquad2.setBandpass(ii, 500.0f, 5.0f);
    }
    for(int ii=0;ii<4;ii++)
      biquad3.setBandpass(&Coeff[ii*5],ii, 100.0f, 10.0f);
    biquad3.setCoefficients(4,(const float*)Coeff);
  //
  noise1.amplitude(0.8);
  noise2.amplitude(0.8);
  noise3.amplitude(0.8);
  
  sine1.amplitude(0.8);
  sine1.frequency(800.0);

  mixer1.gain(0,1.0);
  mixer1.gain(1,1.0);
  mixer1.gain(2,1.0);
  mixer1.gain(3,0.0);

  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  AudioInterrupts();
}


void loop() {
}
uses the float biquads from post #7

obviously, you can implement your own design in post #4
 
Woooww... this is so great ! Thank you, WMXZ for your help.

Well, your posts #8 and #9 seems so be the solutions for the sounds. I need to play with them to complete the sounds but it's definitely a good start.

To answer your question / reflexion, I wanted to keep the 800 Hz in the "windy sound" because I'm trying to get this feeling that the wind is wailing, as a human voice maybe :) When you goes more in a noisy thing, I find it too "windy" and less "human" (of course, it's a point of view). Mixing it with this 800 Hz gives this wailing effect I'm looking for, even if I need to introduce a little bit of random in this 800 Hz cycle !

Thanks again ! I'll let you know how it goes :) !
 
Woooww... this is so great ! Thank you, WMXZ for your help.

Well, your posts #8 and #9 seems so be the solutions for the sounds. I need to play with them to complete the sounds but it's definitely a good start.

To answer your question / reflexion, I wanted to keep the 800 Hz in the "windy sound" because I'm trying to get this feeling that the wind is wailing, as a human voice maybe :) When you goes more in a noisy thing, I find it too "windy" and less "human" (of course, it's a point of view). Mixing it with this 800 Hz gives this wailing effect I'm looking for, even if I need to introduce a little bit of random in this 800 Hz cycle !

Thanks again ! I'll let you know how it goes :) !

You are very welcome!
 
Or if you really want
mixture of tonal and fuzzy noise
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

#include "filter_biquad_f.h"

// GUItool: begin automatically generated code
AudioSynthNoiseWhite     noise1;         //xy=165,99
AudioSynthNoiseWhite     noise2;         //xy=173,205
AudioSynthWaveformSine   sine1;          //xy=175,298
AudioSynthNoiseWhite     noise3;         //xy=176,390
AudioFilterBiquad_F        biquad3;        //xy=342,389
AudioFilterBiquad        biquad1;        //xy=352,98
AudioFilterBiquad        biquad2;        //xy=352,203
AudioEffectMultiply      multiply1;      //xy=366,291
AudioMixer4              mixer1;         //xy=568,152
AudioOutputI2S           i2s1;           //xy=749,154
AudioConnection          patchCord1(noise1, biquad1);
AudioConnection          patchCord2(noise2, biquad2);
AudioConnection          patchCord3(sine1, 0, multiply1, 0);
AudioConnection          patchCord4(noise3, biquad3);
AudioConnection          patchCord5(biquad3, 0, multiply1, 1);
AudioConnection          patchCord6(biquad1, 0, mixer1, 0);
AudioConnection          patchCord7(biquad2, 0, mixer1, 1);
AudioConnection          patchCord8(multiply1, 0, mixer1, 2);
AudioConnection          patchCord9(mixer1, 0, i2s1, 0);
AudioConnection          patchCord10(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=620,442
// GUItool: end automatically generated code

float Coeff[4*5];

void setup() {
  // Audio requires memory to work.
  AudioMemory(16);

  AudioNoInterrupts();

    for(int ii=0;ii<4;ii++)
    {
      biquad1.setBandpass(ii, 400.0f, 5.0f);
      biquad2.setBandpass(ii, 500.0f, 5.0f);
    }
    for(int ii=0;ii<4;ii++)
      biquad3.setBandpass(&Coeff[ii*5],ii, 100.0f, 10.0f);
    biquad3.setCoefficients(4,(const float*)Coeff);
  //
  noise1.amplitude(0.8);
  noise2.amplitude(0.8);
  noise3.amplitude(0.8);
  
  sine1.amplitude(0.8);
  sine1.frequency(800.0);

  mixer1.gain(0,1.0);
  mixer1.gain(1,1.0);
  mixer1.gain(2,1.0);
  mixer1.gain(3,0.0);

  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  AudioInterrupts();
}


void loop() {
}
uses the float biquads from post #7

obviously, you can implement your own design in post #4
I am wondering what is the "filter_biquad_f.h" and "AudioFilterBiquad_F".
 
It's a floating point (rather than integer) version of the biquad filter - see post #7
I saw the previous comment about post #7 but cannot find the part about "filter_biquad_f.h". I see something like "attachment", but not clickable.
 
for me there is clickable attachment at #7 with a zip file with the filter_biquad_f.h, filter_biquad_f.ino and a test sketch - are you looking at it on a phone?
 
for me there is clickable attachment at #7 with a zip file with the filter_biquad_f.h, filter_biquad_f.ino and a test sketch - are you looking at it on a phone?
On computer only. Strange. This is the page code, nothing linked:
Code:
<fieldset class="postcontent">
<legend><img src="images/misc/paperclip.png" class="inlineimg" /> Attached Files</legend>
<ul>
<!-- BEGIN TEMPLATE: postbit_attachment -->
<!-- END TEMPLATE: postbit_attachment -->
</ul>
</fieldset>
 
In Safari instead of Firefox I see now the link.
Code:
								<legend><img src="images/misc/paperclip.png" class="inlineimg" alt="Attached Files" /> Attached Files</legend>
								<ul>
								<!-- BEGIN TEMPLATE: postbit_attachment -->
<li>
	<img class="inlineimg" src="images/attach/zip.gif" alt="File Type: zip" />
	<a href="attachment.php?attachmentid=11247&d=1502552661">TestReson.zip</a> 
(5.3 KB, 71 views)
</li>
<!-- END TEMPLATE: postbit_attachment -->
								</ul>
							</fieldset>
Funny the postbit_attachment is not interpreted in Firefox.

The code in the ZIP file looks interesting to me.
Thank you for the info!
 
Status
Not open for further replies.
Back
Top