Pops & Clicks sending simple Blender animations to OsciStudio


#1

OsciStudio Version: 6.0.38
Operating System: MacOS 10.14, Windows 10 latest
Audio Interfaces: Motu16a, Focusrite Clarett2 Pre, 192kHz, 2048 / 4096 buffer
Blender: 2.83.9 & 2.83.7
Blender->OsciStudio oscistudio.py verison 1.5
downloaded from “Blender 2.82 and Oscistudio - connection issues
https://forum.oscilloscopemusic.com/uploads/default/original/1X/130db727a8bc7f8e450ccf3cc7bb002f8cb28bd9.py

When I create a simple animation in Blender (1080p, 60fps), successfully Connect to OsciStudio and “Send Animation”, the animation successfully sends over. Then when I animate the Time onto my timeline, my final output bounced to disc “bouncy.wav” always has pops & clicks in it.
Can someone please help me find a way to export these animations cleanly?

My hardware is quite powerful, esp on the Windows setup, so I don’t think the problem lies there.

FYI I measured that my loop (3/4 time 85bpm 8bars) is = 16.9412 sec
So I chose my Animation Frame length in Blender as: 1017 frames at 60fps

Attaching the Blender project file that I want to come out clean; But I also have pops & clips with a simple rotating cube. What could possibly be the problem with my setup?

Blender Project: Hyperloop
Experimental Version w Vamp: Hyperloop-Exp

Thanks,
Rich DDT


#2

Note, we are also experiencing the pops & clicks using Vamp v2.83
Preventing us from even making a simple Cube (w back faces removed) that looks like this - but without pops & clicks:
Test Cube wav
Test Cube Blender Vamp’d
Test Cube OsciStudio .txt


#3

Can @kritzikratzi or @zippy731 help us out?


#4

Hmm. This is interesting to me. I am able to replicate the clicks & pops when I test out on my setup. I’ve also got a powerful Windows 10 PC, and using 96K sample rate and ASIO that I always use.

For this test, I used OsciStudio 0.6.0.31, and Blender 2.83. I’m using the same oscistudio.py that @richddt mentioned.

A couple of things:

Once the animation is sent to OsciStudio (OS) from VAMP / Blender, Blender has no more role and can be disconnected from OS and closed. As you note, even a simple cube being animated in Blender (not using VAMP) will also cause the issue.

The problem here is clearly located in the way that OS interacts with the audio drivers.

It seems that the problem specifically occurs when OS switches between Blender animation frames. If you freeze the timeline animation in OsciStudio and just run an FX in OsciStudio (rotation, etc,) you will not hear the pops. Also, I did a test with no imported animation, nor VAMP. I just connected Blender to OsciStudio directly and manually rotated the simple cube in Blender. The pops and clicks occurred again.

To me, the sound reminds me of the pops you get if you play an audio sample that does not start/end at zero crossing. In those situations, there’s a sudden step from non-zero to zero, causing a click or pop.

Looking at the waveform from your sample, I do see discontinuities in the waveforms which I believe account for the noise. This is a close-up of your .wav sample, just one audio channel for clarity:

In the first section, the audio was nice and clean. The clicks started at the location I’ve marked, and you can see some zero crossing / discontinuities circled.

If OsciStudio doesn’t have any sort of audio transition between frames, I could see this being the case.

@kritzikratzi - does OsciStudio just jump cut immediately to the next frame when creating audio from imported Blender animations?

Would it be possible to have the audio fade between the previous and current animation frame, maybe over a couple of audio cycles?

Or alternately, when switching to a new animation frame, ramp the current audio down to zero, then ramp up the new sample from zero, again over a few samples in order to mitigate the pops?

@richddt - For your project, you could manually edit the .wav files for to make all of the frames into zero crossings, but that would be a major PITA given 1000 frames x however many animations you’re creating.

As an aside, in my recent projects I’ve been sending very complex (and thus noisy) images from Blender to Oscistudio, so I wouldn’t notice a couple of pops or clicks amid my noisy results.

One other thing I’ll mention is that I’ve been using OS for a couple of years, and I am pretty sure that when I first started using it, (with Blender 2.7x and Oscistudio 0.5x,) I did not have this problem.

I recall that when Blender came out with 2.8x, and @kritzikratzi was working on OS 0.6x, he did some refactoring of the interactions between Blender and OsciStudio, so I wonder if anything changed in the audio generation code at that time? I’ll try to re-run this test using old Blender and old OsciStudio and see if those clicks and pops are still there.


#5

OK, I just did another quick test, using old OsciStudio (A5.5) and old Blender (2.79b).

When I connect with the simple blender cube, and just rotate the blender cube by hand, I do not get the same level of pops and clicks. I get the occasional crackle, but that’s mainly just when I move it quickly.

So, @kritzikratzi it does seem like maybe something changed in the audio generation code between version 5.5 and version 6?


#6

@richddt - some other thoughts on how to reduce the noise with current OsciStudio:

  1. If the noise is coming from switching between frames, consider reducing the total frame count in your animation. I typically create my animations at 24fps in blender, then just send them over to oscistudio and tune the speed/frequency to my needs. n10

  2. Also, there are some FX inside of OsciStudio that could help. For instance, if you put just a LITTLE bit of trace, you can move the zero crossing around. If you turn on ‘Grid’ and reduce the spread to zero, OS will draw the same shape over the same location multiple times, and will increase the audio frequency. If you reduce the master frequency to offset this, then the transitions between frames may not be as pronounced.


#7

@zippy731 your in-depth analysis is truly appreciated here, thanks for investigating so thoroughly!! You always have stunning results in your own work, so I figured you would know. Trying those clever tricks asap! Thanks again.

I’m dreaming of seeing Vamp baked into a future release of OS, with fully encapsulated animations that can be rotated arbitrarily within that environent rather than being tied to the camera movements in Blender.

Althought the better I get in Blender, the more I see its great potential, like specifying more accurate keyframes that will yield more consistent rendered output on the timeline, vs the more unpredicatable results of rendering OS’s LFO’s. And of course, unlocking rigged internal & inter-object animations :slight_smile:


#8

Glad to help. I’ll keep thinking about other workarounds, as this is a universal problem affecting any animation sent from Blender.

If Hansi can’t tweak the per-frame transition, I might be able to update VAMP to arrange the verts & edges in a more optimal arrangement…

Will mull it over.


#9

yea… every frame has the vertices in different places, so the perfect traversal order changes. you hear this as a crack.

i have no general solution for this type of issue, but two things come to mind:

SPECIAL SOLUTION 1: Manually fix edge traversal

there is a remedy if you have the exact same mesh in each frame, and you only move stuff around (morphing is fine, but connections between vertices can’t be removed or added).

the idea is to force every frame in the animation is to use the same travesal order,
we can do that manually in a texteditor.

  1. you will require a texteditor with good regular expression support (i used textmate)

  2. send the animation from blender into oscistudio, save that file (you might destroy the file soon, so definitely only work on a copy!)

  3. open the file in the texteditor

  4. search for "lines": (including quotes and the colon)

  5. you should find a section that lists the edges for the object, followed by the name of the object. for me it looks like this:

     		"lines": [ {97 47}{47 80}{80 29}{29 96}{96 66}{66 79}{79 46}{46 16}{16 34}{34 3}{3 49}{49 19}{19 61}{61 83}{83 39}{39 9}{9 27}{27 5}{5 31}{31 13}{13 62}{62 23}{23 65}{65 17}{17 35}{35 4}{4 43}{43 13}{13 51}{51 20}{20 50}{50 10}{10 40}{40 0}{0 36}{36 18}{18 53}{53 20}{20 52}{52 9}{9 59}{59 22}{22 61}{61 94}{94 34}{34 78}{78 67}{67 77}{77 69}{69 24}{24 68}{68 79}{79 41}{41 81}{81 64}{64 82}{82 31}{31 90}{90 51}{51 89}{89 48}{48 4}{4 48}{48 18}{18 71}{71 25}{25 70}{70 14}{14 32}{32 6}{6 29}{29 11}{11 63}{63 23}{23 64}{64 8}{8 26}{26 7}{7 46}{46 85}{85 60}{60 84}{84 27}{27 9}{9 39}{39 1}{1 39}{39 91}{91 50}{50 92}{92 36}{36 75}{75 72}{72 15}{15 33}{33 2}{2 42}{42 12}{12 67}{67 24}{24 66}{66 11}{11 41}{41 7}{7 46}{46 16}{16 34}{34 3}{3 30}{30 88}{88 56}{56 87}{87 28}{28 91}{91 52}{52 90}{90 27}{27 5}{5 38}{38 8}{8 60}{60 22}{22 58}{58 16}{16 68}{68 78}{78 30}{30 12}{12 54}{54 21}{21 56}{56 19}{19 37}{37 1}{1 28}{28 10}{10 55}{55 21}{21 57}{57 86}{86 40}{40 92}{92 53}{53 89}{89 43}{43 95}{95 65}{65 80}{80 63}{63 81}{81 26}{26 85}{85 58}{58 94}{94 49}{49 88}{88 54}{54 93}{93 33}{33 76}{76 70}{70 97}{97 73}{73 74}{74 35}{35 95}{95 62}{62 82}{82 38}{38 84}{84 59}{59 83}{83 37}{37 87}{87 55}{55 86}{86 45}{45 75}{75 71}{71 74}{74 48}{48 18}{18 36}{36 0}{0 45}{45 15}{15 57}{57 93}{93 42}{42 77}{77 44}{44 2}{2 44}{44 14}{14 32}{32 6}{6 47}{47 17}{17 73}{73 25}{25 72}{72 76}{76 44}{44 14}{14 69}{69 96}{96 32}{32 97}]
     		"name":"Cube"
    
  6. “Cube” is what i was looking for (lucky me!). copy the line order, ie. [ {97 47}{47 80}....{32 97}]

  7. Open the search and replace dialog:

    Search for: (?<=\t{4}"lines": ).*(?=\n\t{4}"name":"Cube")
    Replace with: [ {97 47}{47 80}…{32 97}] (use the traversal order you found in your file earlier)
    Make sure the “Regular Expression” option is on in the search window.

  8. Save your file, and reload it in oscistudio.

if you run into trouble doing this, send your oscistudio file and i’ll try to take a look.

SPECIAL SOLUTION 2: Cross fade between animation frames

depending on the situation you might also want to cross-fade between frames.
this is sortof possible in oscistudio with a short livecoding thing, but then you can only easily use a single shape.

you’ll have to tweak this for your needs (it assume an object called “Cube” in the first track)

// shape you want to use
SHAPECALL(shape, "Cube");
// "Terminate0>Time" is the UID of the "Time" slider in the channel 
SLIDER_EXT(ani_t_ext, "Terminate0>Time");

SLIDER(cross_ms, 0..1000);
PHASOR(timeout).setVisible("t,freq",false);

long last_ani_t = 0; 
long ani_t = 0;
long prev_ani_t = 0; 

bool filter_active = false; 

void setup(){
	timeout.oneShot = true; 
}

void update(){
	filter_active = timeout.t<1;
	timeout.setPeriod(max(0.001,cross_ms)/1000.0);

	if(!filter_active){
		ani_t = ani_t_ext;
		if(last_ani_t != ani_t){
			trace((int)ani_t);
			prev_ani_t = last_ani_t;
			timeout.reset(); 
		}
		last_ani_t = ani_t; 
	}
}


vec3 gen(float t){
	if(filter_active){
		return blend(timeout, shape(t,prev_ani_t), shape(t,ani_t));
	}
	else{
		return shape(t,ani_t);
	}
}

#10

thanks @kritzikratzi!

I think since @richddt has a blender animation here (i.e. different mesh in each frame,) that the crossfade solution would be more applicable.

I loaded your code into a saved version of his animation, and loaded your new crossfade code into the livecoding plugin, but it’s not working for me. If you have a minute, could you look at it? Here’s a link to the animation, with the livecoding plugin added:

https://drive.google.com/file/d/17BWxS_nnyGLAowkTGHL2V8KeMw7-93eo/view?usp=sharing

If you play the timeline with the livecoding switched off, you can see the animation looping (with the pops and cracks.) If you turn on the livecoding, the animation freezes at a single frame. I think I missed a step in your instructions? Is this supposed to work with just playing/scrubbing the animation? Or do I need to render the timeline out to a .wav to see the impact?


#11

So grateful that two of the great ones are using my Blender animated Hyperloop as a test example here.
Fingers crossed this becomes a solution that we can all use!


#12

ok, i’ve changed the code a tiny bit so it should work with A6 (sorry…)

RichDT_Hyperloop_Vampd_Test.1.os.zip (2.2 MB)

you can get interesting results with some values (0-10ms)

here is the updated code:

// shape you want to use
SHAPECALL(shape, "_flatSliced");
// set end of range to the number of frames in your animation
SLIDER(ani_t_ext, 0..1017);

SLIDER(cross_ms, 0..10);
PHASOR(timeout).setVisible("t,freq",false);

long last_ani_t = 0; 
long ani_t = 0;
long prev_ani_t = 0; 

bool filter_active = false; 

void setup(){
	timeout.oneShot = true; 
}

void update(){
	filter_active = timeout.t<1;
	timeout.setPeriod(max(0.001,cross_ms)/1000.0);

	if(!filter_active){
		ani_t = ani_t_ext;
		if(last_ani_t != ani_t){
			prev_ani_t = last_ani_t;
			timeout.reset(); 
		}
		last_ani_t = ani_t; 
	}
}


vec3 gen(float t){
	if(filter_active){
		return blend(timeout, shape(t,prev_ani_t), shape(t,ani_t));
	}
	else{
		return shape(t,ani_t);
	}
}

#13

Yes, working now for me! At a low number (0.3) on the cross_ms slider, I think it does a good job of reducing the pops. Running the animation all the way through, makes for some cool harmonic crackles as well!

I see what you mean about working on just a single shape. I think it’s a good hack for this purpose, and will tame pops for lots of shapes!

Also @richddt - you need to animate the ani_t_ext value for this to work, not the usual Time slider.

I think this is a nice FX and would encourage it to be officially added (frame_crossfade) in a future osci release!

I put a trace behind it, and think it’s pretty dope now. still some pops, but they’re embedded in the sound.

Here’s the updated project for Rich, with my edits.

https://drive.google.com/file/d/1pPAN08hQPTU8JVMScrmhKua7YdzBj2Yk/view?usp=sharing


#14

Wow - thank you @zippy731& @kritzikratzi! @zippy731 your edit of my OsciStudio project is quite cool, honored that you shared it! Filled with harmonic crackles, so to speak - which visually make unexpected beam jumps from edge to edge that resemble jolts of electricity. Gritty, but so much better than the pops & clicks from before!

This brings a huge smile to my face and I’m excited to get this integrated into the greater sci-fi theme of the installation!! Thanks for clearing this path forward for me and all other Blender-loving artists :star_struck:


#15

Glad to help, Rich. That animation is very cool looking! It is pretty complex with lots of lines to start with, so at some level, the noise is unavoidable.

One other thought: if you need to reduce the noise further, you can just mark-sharp the edges you want to keep, and use the "Freestyle’ mode when you send it through vamp.

I did a quick test of that here with your project:

https://drive.google.com/file/d/1GtO4tgMJ_nh11zkjY1sLYNfbrAvMYtUe/view?usp=sharing

The freestyle marking in vamp is meant for this situation: maintain the key lines that define the shape, but reduce the total vert/line count being sent to Oscistudio.

HTH
-Z


#16

Just as a thought has the possibility of latency regarding the sound been explored? I use music/sound with 3DS Max animations from a DAW and I had similar clicks going on that were solved by reducing the latency caused by certain elements of Windows. I spent 15 years doing tech-support and this feels like one of those “the pieces are clicking into place” type events :stuck_out_tongue: I could be talking out of my rear of course :smiley: (An easy test is using the LatencyMon from https://www.resplendence.com/main (it’s free and very light weight)