AudioResearchBlog

Covering all audio related stuff with special focus on programming and digital signal processing

Showing a little about CLAM as a prototyping tool at the Audio Club of FIUBA

Posted by hordia on August 17th, 2009

Last week, at the recent ‘audio club’ of my university, I was showing how to work with the CLAM framework as a tool to prototype realtime audio signal processing applications in a simple and fast way.

We started with an example network to show some about the NetworkEditor capabilities: karaoke.clamnetwork
Karaoke

After that, we continue with a simple ‘diodo distortion’ plugin:

We specified and generated the source code base in this way:
Especificación de distorsión tipo diodo

We wrote this code:

bool Do()
        {
            bool result = Do( mEntrada.GetAudio(), mSalida.GetAudio() );
 
            mEntrada.Consume();
            mSalida.Produce();
 
            return result;
        }
   
        bool Do(const Audio& in, Audio& out)
        {
            int size = in.GetSize();
 
            const DataArray& inb = in.GetBuffer();
            DataArray& outb = out.GetBuffer();
 
            for (int i=0;i<size ;i++)
            {
                if ( fabs(inb[i])>0.8 )
                    outb[i] = inb[i]&lt;0.? -0.8:0.8;
                else
                    outb[i] = inb[i];
            }
            return true;
        }
</size>

And built this net to try it:
Red para probar distorsión de diodo

The source code of the plugin ready to be compiled is here: pluginDistorsiónDiodo_ClubAudioFiuba.tar.gz

As extra, I leave here pluginDistorsiónDiodoConControlDeClipping_ClubAudioFiuba.tar.gz the same diode distortion, but with a clipping control to set the threshold when playing.

They liked these kind of prototyping features a lot, so probably we’re going to keep using it at the club.


, , , , , , ,

Posted in audio, effects, signal processing, programming, English, CLAM, plugins, ClubAudioFiuba | No Comments »

Interactive CLAM programming (with python)

Posted by hordia on August 3rd, 2008

Recently I been playing with python bindings for the CLAM library. Here is a demo demonstrating how to interactively build a network and play a file using the IPython shell:


 
Related scripts: playfile.py fft_example.py.
 
PyCLAM source. INSTALL.


, , , , , , , , , , ,

Posted in audio, signal processing, free software, programming, GPL, c++, libraries, python, projects, English, CLAM, ideas | No Comments »

CLAM processing generator script (example of use)

Posted by hordia on July 7th, 2008

This script is about a basic code generation of a CLAM plugin. In some point I think this is some kind of meta-programming or perhaps the term “automatic programming” fits better. The basic idea is to specify some basic features of the planned new processing in a plain text and then, generate some code with the script, saving in this way many of the often repetitive and mechanical work needed to set-up a new processing from scratch. Main intention is to allow concentrate in the Do() function or plugin details quickly.

As an example, I will reproduce here how I worked with me some time ago:
 
One day, in the irc #clam channel:
“[11:51] <groton> Consul, do you know if there is any trigger-like processing unit, list when the volume gets louder than a threshold or something like that”

I’m not Consul in the irc (I’m hordia), but next day at my console…

cd CLAM/scripts/TemplatedPluginsGenerator
vi ThresholdTrigger.template

Name:ThresholdTriggerTemplate
BaseClass:Processing
i:AudioInPort,Audio Input
ic:0,1,Threshold
oc:0,1,Trigger

In words, this means a Processing template named “ThresholdTriggerTemplate” using “Processing” as a base class and with one input of “AudioInPort” type named “Audio Input”, with one in control in the 0..1 range named “Threshold” and one out control named “Trigger”. Of course, you can add as many inputs/outputs of ports or controls as you want.
 

This script creates the template:

./TemplateGenerator.py ThresholdTrigger.template

 
And this one the processing plugin:

./TemplatedPluginsGenerator.py ThresholdTrigger ThresholdTriggerTemplate "Hernán Ordiales" GPL 2008

Again in words, this means create a new processing called “ThresholdTrigger” based on the “ThresholdTriggerTemplate” filling the copyright with my name plus the current year and the license with the GPL text.

 
A final edit just typing the required code for the Do() function:

cd CLAM/plugins/ThresholdTrigger
vi ThresholdTrigger.hxx

#include <cmath>
 
bool Do()
{
       bool result = Do( mAudioInput.GetAudio() );
       mAudioInput.Consume();
       return result;
}
 
bool Do(const Audio& in)
{
       int size = in.GetSize();
       const DataArray& inb = in.GetBuffer();
       TData threshold = mThreshold.GetLastValue();
       bool trigger = 0;
       for (int i=0;i<size ;i++)
       {
               if (std::fabs(inb[i])>threshold)
                       trigger = 1;
       }
       mTrigger.SendControl(trigger);
       return true;
}
</size></cmath>

At this point, just remains add the basic SConstruct file for a CLAM plugin, compile it with the corresponding clam_prefix and install it:

scons install clam_prefix=$CLAM_PATH
NetworkEditor

And ready to use…

This example it’s very simple and has a poor implementation but was just to show the idea of how those scripts can save a lot of work.

Update: I made a frontend for these scripts: ProcessingCodeGenerator


, , , , , , , ,

Posted in audio, programming, c++, python, English, CLAM, plugins, library | 1 Comment »

Distortion rack prototype

Posted by hordia on January 5th, 2008

A nice prototype:

CLAM distortion rack prototype

 
 

And the net behind:

CLAM distortion rack prototype


, , , , ,

Posted in effects, English, CLAM, GUI, sound | No Comments »

LADSPA versions of my recent simple distortions

Posted by hordia on December 17th, 2007

After prototype different kind of simple distortions in NetworkEditor i managed to port all them to ladspa plugins. Despite the fact that the task was less difficult than i had expected at first, prototype with CLAM first worth a lot. Probably, if i had begun coding directly to ladspa source, reach the same status would be taken to me 10 or more times more. I think also was very interesting as “development process”, instead of modeling for example with matlab, you could easy modeling (among other things) in CLAM, and then, if you want/need make your final product by your own.

More, the other day i learned that is already possible to compile ladspa plugins directly from CLAM networks… very cool! Though i think this feature is not completely ready yet and i’m still have to dig in it, i don’t think that i have lost time porting manually because now i have a better knowledge and understanding about ladspa specification that for sure will be useful to work with this (for me “new”) feature, that probably needs some fixes.

About the ladspa plugins programming, i just downloaded the sdk from ladspa.org, read some of the ladspa.h file and some basic examples (the ones from sdk) and that was enough to handle the basis. Ah, i had to ask for some ladspa ID’s for my plugins here: ladspa at muse.demon.co.uk

On the other hand i’ve forwarded my distortion examples to musix distro folks and some of them indeed have tried it and made a couple of jack-rack presets and audio demos. More info about this here: DSP-es#Presets, ogg demos and jack-rack presets, and patchs review.

Next step (in my TODO list): produce ladspa binaries directly from CLAM networks.

I have uploaded these plugins here: disthordian ladspa plugins.


, , , , , , , , , ,

Posted in audio, algorithms, effects, free software, programming, c++, libraries, English, CLAM, plugins, specifications | No Comments »

New CLAM plugin: (’very’ for now) simple guitar distortion

Posted by hordia on December 9th, 2007

A week or more ago, Daniel Vidal Chornet (collaborator of Musix) asked me if i can develop guitar distortion effects, because he couldn’t find something decent that suits his needs, i said “sadly i have no idea about distortions effects and anyway i have no time right now to do that”, but then i remembered how useful could be the clam framework and i tried to do a little spike about. Results were better than i had expected at first (is not a super cool distortion, but at least sound like one).

Basically i merged and tweaked a couple of simple/base algorithms found in the web for distortion and compression and in less than 30 minutes i had something working and sounds like a guitar distortion (”clean” ones seems to sound better easily). I was amazed how fast and easy (develop and test in clam/networkeditor, once you get the basis) was. I think right now is far to be a good distortion, but as learning process and first demo seems very good.

Here some sound examples:

Original:
(dvlc-guitar.ogg)

With distortion:
(guitardist-ex1.ogg)

Test network looks like:

Distortion NE network

 

The source code is here (as NetworkEditor plugin): GuitarDistortion.tar.gz

Some optional tweaks could include add a three band filter but i’m still not sure if it’s better to put it at first or at the end.

Special thanks for testing and audio samples to Daniel Vidal Chornet. I should take from my closet my fender stratocaster and do my own samples :-D . OTOH, we already arrange to do a remote gig with this.

Another useful NetworkEditor processings plugins i had made during this “work”:

  • AutomaticGainControl: Adaptative automatic gain control. Given an output reference and step response adjusts the output volume to keep it constant (AutomaticGainControl.tar.gz)
  • AudioSwitch: Switchs between a configurable amount of inputs (like a multiplexer) (AudioSwitch.tar.gz)

 
Related: LADSPA versions of my recent simple distortions
Update: Distortion rack prototype


, , , , , , , , , ,

Posted in audio, algorithms, effects, free software, programming, GPL, c++, English, CLAM, plugins, library | 4 Comments »

My presentation at the “VI Jornadas de Acústica, Electroacústica y áreas vinculadas (CADAE)”

Posted by hordia on October 27th, 2007

Yesterday I had the opportunity to give a talk about my recent work in the google summer of code at the VI Jornadas de Acústica, Electroacústica y áreas vinculadas (CADAE). The given time was short, so was a little hard to explain all in only 20 minutes, but seems that all went well (at least seemed like the people). Here my presentation (in Spanish):

 

Transformaciones espectrales en tiempo real para CLAM

 

Download: Transformaciones espectrales en tiempo real para CLAM.pdf

 


, , , , , , , , , , , , , , , , , ,

Posted in audio, acoustics, algorithms, effects, signal processing, free software, programming, GPL, c++, libraries, midi, English, CLAM, GSoC2007, GUI, talks, dissertation, events, conferences | No Comments »

Fundamental (in Hz) to a MIDI note

Posted by hordia on August 26th, 2007

Working to have audio-to-midi in NetworkEditor (CLAM) I needed to convert a fundamental frequency value to a MIDI note one.

I found some source code related with this in Voice2MIDI app, but was not explained at all, so looking for the reason of that formula I arrived at this:

Knowing about equal-tempered scale (check this) and 2^{\frac{n}{12}} relation between frequencies plus the fact that C4 or “middle c” has a MIDI value of 60, it’s easy to conclude that then A4 (which its frequency value is 440Hz, a standard for tunning and is 9 semi-tones more) has a MIDI value of 69.

 

Then, starting with:
fundfrec = 440Hz * 2^{(\frac{1}{12})^n}

 

It’s easy to arrive at this:
fund_{midinote} = 69+log_{2^{(\frac{1}{12})}}(\frac{fundfrec}{440Hz})

 

and then, also taking in account this mathematical relation::
log_{2^{\frac{1}{12}}}(a) = log_{e}(a)*17.31234

 

the final formula looks like:
fund_{midinote} = 69+log_{e}(\frac{fundfrec}{440Hz})*17.31234

 

and a final c++ code like:

fund_midinote = round( 69. + log(fundfrec/440.)*17.31234 );

 
Related post: nictuku’s inverse formula (i.e. from MIDI to Hz) here “Translanting MIDI Notes to frequencies in the diatonic scale using the central A (440hz) as reference“.


, , , , , , , , , ,

Posted in audio, algorithms, programming, music theory, c++, midi, math, English, CLAM, standards, GSoC2007 | No Comments »

SMS interference mystery solved

Posted by hordia on August 8th, 2007

Andrés Kasulin, a friend of mine from the University gave me some light about the issue of SMS interference (check “Catching (phone) SMS pulse train with CLAM…“)

He says in a comment from that post:

“I’ve found nice data in wikipedia[1].

It seems to be radiofrequency interference produced by the the phone, and filtered by the mic-cable-probes-osciloscope system. I think there is only a square pulse because the carrier frequency is much higher than filter cutoff frequency (maybe near 10^5 times).”

[1] http://en.wikipedia.org/wiki/GSM#Radio_interface

 
 

I’d add from that article:

“A nearby GSM handset is usually the source of the “dit dit dit, dit dit dit, dit dit dit” signal that can be heard from time to time on home stereo systems, televisions, computers, and personal music devices. When these audio devices are in the near field of the GSM handset, the radio signal is strong enough that the solid state amplifiers in the audio chain function as a detector. The clicking noise itself represents the power bursts that carry the TDMA signal. These signals have been known to interfere with other electronic devices, such as car stereos and portable audio players. This is a form of RFI, and could be mitigated or eliminated by use of additional shielding and/or bypass capacitors in these audio devices. However, the increased cost of doing so is difficult for a designer to justify.”

Very thanks Andrés!


, , ,

Posted in audio, noise, hardware, English | 1 Comment »

Many files to stream with cortado in the same page

Posted by hordia on August 6th, 2007

Recently I’ve added cortado applet to my server to have ogg streaming (check this) in this blog… but then I realized that does not work with many applets in the same page… (bad for a blog) so I had to move the streaming parts to many separate (new) html pages (for example one for each post or topic)

And for each one add a code like this one:

<body>
   <script language="javascript">
     function restart() {
       document.applets[0].restart(); 
     }
     function loadUrl(uri, audio) {
       document.applets[0].setParam("audio", audio); 
       document.applets[0].setParam("url", uri); 
       restart();
     }
   </script>
<applet archive="../cortado-ovt.jar" code="com.fluendo.player.Cortado.class" width="320" height="20">
<param name="url" value="" />
<param name="local" value="false" />
<param name="framerate" value="5.0" />
<param name="keepaspect" value="true" />
<param name="video" value="false" />
<param name="audio" value="true" />
<param name="seekable" value="true" />
<param name="autoPlay" value="false" />
<param name="duration" value="200" /></applet>
 
<button onClick="loadUrl('http://audiores.uint8.com.ar/files/audios/morph/Piano.ff.C5-mono-short.ogg', 'true')">
    Piano C5
   </button>
   <button onClick="loadUrl('http://audiores.uint8.com.ar/files/audios/morph/oboe.mf.C5B5-mono-short.ogg', 'true')">
    Oboe C5
   </button>
   <button onClick="loadUrl('http://audiores.uint8.com.ar/files/audios/morph/take1.ogg', 'true')">
    Take1
   </button>
   <button onClick="loadUrl('http://audiores.uint8.com.ar/files/audios/morph/take2-inverted.ogg', 'true')">
    Take2
   </button>
 </body>

To have something like this: streaming morph demos.


, , , , ,

Posted in audio, programming, English, web, java, flash | No Comments »

 
Cerrar
Enviar por Correo