Live scrolling waveform display

Jun 2, 2008 at 4:52am

Live scrolling waveform display

Hello,

I have been trying to come up with all sorts of workarounds for this, but I wanted to know if anyone had a nice simple solution.

I’m looking for a way to take a live signal and constantly display the previous n seconds of it, kind of like a cross between a waveform~ display and a spectroscope~ in sonogram mode (or multislider in reverse line scroll mode).

I can do it with a redrawing waveform~, but I wonder if there is a nicer way:

– Pasted Max Patch, click to expand. –
#38198
Jun 2, 2008 at 6:54am

lcd is an option:

– Pasted Max Patch, click to expand. –
#132854
Jun 2, 2008 at 10:30am

That’ll do nicely for what I need

Cheers jkvr!

For the Cycling developers, how easy would it be to add further functionality to spectroscope~ that did an amplitude display like this? Rhetorical question really…

#132855
Jun 2, 2008 at 12:30pm

On 2 juin 08, at 12:30, Alex Mesker wrote:

> That’ll do nicely for what I need
>
> Cheers jkvr!
>
> For the Cycling developers, how easy would it be to add further
> functionality to spectroscope~ that did an amplitude display like
> this? Rhetorical question really…

Spectroscope~ is designed to make a FFT analysis. It wouldn’t make to
much sense to add that feature here. IMHO, the lcd solution is good
enough.

ej

#132856
Jun 4, 2008 at 10:05pm

Along the lines of the spectroscope~, I was wondering if, since it’s done some kind of FFT already, whether there could be an outlet which spits out lists of bins/amplitudes. So you wouldn’t need to do a separate FFT yourself, just run it thru the spectroscope and track what’s already going on visually, but have access to the numbers involved too.

If the new one in 5 already does this, my apologies :) and thanks!

I suppose you could do some trickery to achieve this with an exactly-placed and sized spectroscope, using the suckah to read the values graphically :)

-CJ

#132857
Jun 30, 2008 at 5:45am

I ended up reworking the LCD solution that jkvr suggested, as it didn’t accurately represent peaks and the positive & negative values (it just mirrored the positive to make the negative), by using peakamp~ instead of avg~

For anyone that is interested:

– Pasted Max Patch, click to expand. –
#132858
Jun 30, 2008 at 1:55pm

I would be interested in something similar….but my Issue is im on max 4. Does anybody have a patch that I could try in Max 4

#132859
Jul 1, 2008 at 1:41am

I just knocked this up…. give it a try. I haven’t really tested it though

max v2;
#N vpatcher 442 44 1414 827;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 538 41 72 196617 loadmess 255;
#P message 744 163 71 196617 saturation $1;
#P user multiSlider 744 70 16 89 0. 255. 1 2665 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 58 589 55 196617 zl group 3;
#P message 538 163 71 196617 saturation $1;
#P user multiSlider 538 70 16 89 0. 255. 1 2665 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P message 762 246 75 196617 brgb $1 $2 $3;
#P newex 762 265 73 196617 s lcdDrawLeft;
#P newex 762 224 83 196617 pack 0 0 0;
#P number 834 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 798 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 762 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 762 41 78 196617 loadmess 0 0 0;
#P newex 762 181 82 196617 unpack i i i;
#P user swatch 762 69 171 91;
#P newex 557 246 70 196617 s wavecolour;
#P newex 557 224 83 196617 pack 0 0 0;
#P number 629 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 593 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 557 202 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 614 41 90 196617 loadmess 6 172 0;
#P newex 557 181 82 196617 unpack i i i;
#P user swatch 557 69 171 91;
#P newex 107 708 73 196617 s lcdDrawLeft;
#P newex 58 548 107 196617 if $i1==$i2 then bang;
#P message 30 671 138 196617 scrollrect 0 0 480 161 -1 0;
#P message 44 649 135 196617 linesegment 479 $1 479 $2;
#P message 58 626 127 196617 setpixel 479 80 $1 $2 $3;
#P message 168 525 74 196617 frgb $1 $2 $3;
#P newex 168 548 56 196617 route frgb;
#P newex 168 499 70 196617 r wavecolour;
#P newex 30 488 53 196617 t b l l b;
#N vpatcher 357 278 972 792;
#P outlet 133 388 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N coll ;
#P newobj 133 332 53 196617 coll;
#P newex 133 300 78 196617 pack i i i;
#N counter;
#X flags 0 0;
#P newobj 133 255 66 196617 counter;
#P newex 285 198 75 196617 t 0 clear dump;
#P newex 285 133 52 196617 metro 40;
#P toggle 285 99 15 0;
#P newex 285 72 54 196617 dspstate~;
#P newex 167 199 44 196617 unpack;
#P newex 133 199 30 196617 t inc;
#P newex 133 130 44 196617 t b l;
#P inlet 133 83 15 0;
#P window linecount 2;
#P comment 340 129 159 196617 sends out list of peak amps every 40ms/25fps when the dac is on;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 11 0;
#P fasten 8 1 11 0 322 324 138 324;
#P fasten 8 2 11 0 354 324 138 324;
#P connect 11 0 12 0;
#P fasten 8 0 9 2 290 235 166 235;
#P connect 2 1 4 0;
#P connect 4 0 10 1;
#P connect 4 1 10 2;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P pop;
#P newobj 30 383 68 196617 p peakpacker;
#P newex 30 361 30 196617 pack;
#P newex 30 318 31 196617 + 80;
#P newex 30 282 34 196617 + 0.5;
#P newex 30 260 35 196617 * 80.;
#P newex 106 317 33 196617 !- 80;
#P newex 106 281 34 196617 + 0.5;
#P newex 106 259 35 196617 * 80.;
#P newex 399 301 73 196617 r lcdDrawLeft;
#P user lcd 399 333 480 161 0 1 0 0 0;
#P number 165 193 35 9 2 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 117 193 24 196617 +ve;
#P newex 106 230 69 196617 peakamp~ 20;
#P newex 30 230 69 196617 peakamp~ 20;
#P newex 30 191 86 196617 gate~ 2;
#P newex 30 157 31 196617 +~ 1;
#P newex 30 128 39 196617 >=~ 0.;
#P newex 30 84 119 196617 receive~ posnegdistrib1;
#P newex 329 178 105 196617 send~ posnegdistrib1;
#P user ezdac~ 347 131 391 164 0;
#P newex 418 103 38 196617 sel 32;
#P toggle 418 133 15 0;
#P message 329 75 77 196617 open , 1 , loop 1;
#N sfplay~ 2 120960 0 ;
#P newobj 329 95 53 196617 sfplay~ 2;
#P newex 418 74 40 196617 key;
#P window linecount 2;
#P comment 437 126 79 196617 Turn dac on/off with Space Bar;
#P window linecount 1;
#P comment 434 180 64 196617 Left channel;
#P window linecount 2;
#P comment 29 51 226 196617 A peak amplitude analysis is done on the positive AND the negative values in a given time period;
#P user panel 323 69 201 132;
#X brgb 39 127 23;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P comment 6 194 24 196617 -ve;
#P window linecount 4;
#P comment 203 192 105 196617 Analysis time: Output peak amplitudes for every n milliseconds. 10 is a good minimum;
#P window linecount 5;
#P comment 41 418 267 196617 Order or drawing is (right to left out of the trigger object): 1. set colour ; 2. if amp is 0 , then draw a single pixel (at height 80) ; 3. draw line segments denoting positive and negative amplitudes ; 4. scroll the LCD 1 pixel to the left;
#P window linecount 2;
#P comment 373 39 109 196617 To test , load a sample and turn on the dac;
#P connect 15 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 28 0;
#P connect 28 0 29 0;
#P connect 29 0 30 0;
#P connect 27 0 31 0;
#P connect 31 0 32 0;
#P connect 32 0 33 0;
#P connect 33 0 39 0;
#P connect 33 1 38 0;
#P connect 30 0 31 1;
#P connect 33 2 40 0;
#P connect 40 0 61 0;
#P connect 35 0 61 0;
#P connect 61 0 37 0;
#P connect 22 0 19 1;
#P fasten 15 0 18 1 35 113 111 113;
#P connect 18 1 20 0;
#P connect 20 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 27 0;
#P connect 36 0 41 0;
#P connect 39 0 41 0;
#P connect 38 0 41 0;
#P connect 37 0 41 0;
#P connect 22 0 20 1;
#P connect 34 0 36 0;
#P connect 33 3 36 0;
#P connect 36 0 35 0;
#P connect 10 0 9 0;
#P connect 9 0 14 0;
#P connect 9 0 13 0;
#P fasten 11 0 13 0 423 158 410 158 410 120 352 120;
#P connect 9 1 13 1;
#P connect 24 0 23 0;
#P connect 8 0 12 0;
#P connect 12 0 11 0;
#P connect 64 0 59 0;
#P connect 59 0 60 0;
#P fasten 60 0 42 0 543 182 534 182 534 67 562 67;
#P connect 44 0 42 0;
#P connect 42 0 43 0;
#P connect 43 0 45 0;
#P connect 45 0 48 0;
#P connect 48 0 49 0;
#P connect 43 1 46 0;
#P connect 46 0 48 1;
#P connect 43 2 47 0;
#P connect 47 0 48 2;
#P connect 64 0 62 0;
#P connect 62 0 63 0;
#P fasten 63 0 50 0 749 181 739 181 739 67 767 67;
#P connect 52 0 50 0;
#P connect 50 0 51 0;
#P connect 51 0 53 0;
#P connect 53 0 56 0;
#P connect 56 0 58 0;
#P connect 58 0 57 0;
#P connect 51 1 54 0;
#P connect 54 0 56 1;
#P connect 51 2 55 0;
#P connect 55 0 56 2;
#P pop;

#132860
Jul 1, 2008 at 6:43am

Hi,

what about a similar solution to show (after you open it) the
soundfile ‘preview’ ?

That is, not a live scrolling wavefor but a fixed one, loaded when you
‘open’ a soundfile.

All the best


Alessandro Fogar

http://www.fogar.it

2008/6/30 Alex Mesker :
>
> I ended up reworking the LCD solution that jkvr suggested, as it didn’t accurately represent peaks and the positive & negative values (it just mirrored the positive to make the negative), by using peakamp~ instead of avg~
>
> For anyone that is interested:
>
>

– Pasted Max Patch, click to expand. –

>
>
>

#132861
Jul 1, 2008 at 7:23am

Hi sfogar,

For that, I’d use the waveform~ object (if you are loading the sound file into a buffer). Check out the help file.

… or if you aren’t loading a file into a buffer, this is another solution: http://www.cycling74.com/forums/index.php?t=msg&goto=92655&rid=0

I just included a sfplay~ object in my example to test if it was working, but the idea from the beginning was to be able to take a live audio stream and display it (as opposed to loading in a sound file).

#132862

You must be logged in to reply to this topic.