You are reading content from Scuttlebutt
@mmckegg %PupF+M/ghfgPGfGL9NrG1j4Rqx6j6uVTkYh7YyL62Wg=.sha256
Re: %meTZoGO9V

2017-11-22

Alright, here goes! Straight into memory leak debugging first thing in the morning.

I was thinking about a way to test for this. Maybe some kind of automated test that opens a setup and then closes it again measuring the memory usage before and after. But I’m not in the mood for that today. Time to do it the old fashioned way.

Found out that if you call gc() immediately after unreferencing the objects, they do not get garbage collected. But if you call it inside of a requestIdleCallback, they do! This was confusing me as the heap size was not dropping down after closing setups, but it was when measuring with heap snapshots. My initial test setup was not memory leaking, but I did find some that are. Time to start eliminating bits until it stops.

Strange, while the heap snapshotter throws an error when you have a setup loaded, it does not when you close them. UNLESS it is memory leaking, so while it can’t help me find the the leak, it does tell me if it is leaking. Better than nothing.

Found one actual leak (was missing a destroy on the inner chunk for the new mono-synth). However, there is one setup that will always leak if opened first, but if it is opened after another setup, then it doesn’t leak!! WUT!

I’ve left the “gc() purge after closing” enabled. Will see what happens when this is used with a jam. I removed it in the past because it was causing issues with responsiveness when transitioning between songs. But I think this was because my pre-schedule time was too high. Now preschedule is lastGCDuration * 2.

Will have a jam a little bit later with the memory allocation profiler running and see if there is anything that is peaking a bit hot for memory usage. Still need to figure out why the audio goes glitchy when adjusting knobs (but not when javascript profiler is running).

Back to multi-input / output

Just realised that while Web Audio can’t do multi-channel input, it should be able to do multi-channel output. Gonna try and get a proof-of-concept output channel switcher working. Also would be nice to get the input recorder working from yesterday. Looks like the mac bug has been fixed in that module now!

Oh nice! audioContext.destination.maxChannelCount is 10 when connected to my K-Mix.

Made a cute little MultiChannelOutput module that allows you to set the outputs and channel numbers and it will automatically handle all the routing magic and channel counts for you! Next step is to build a user interface on top. But for now, I’m just gonna set it manually!

And yay, it WORKS!!

_But also found an issue with the clap generator (on musical score) NaNing out the sound. Heard there was an issue with filters ... no fix yet.

So further work here would be the ability to select the outputs, and some kind of refresh when the output device changes :construction:

Okay, nearly ready for today’s jam. Let’s see if we can quickly whack out a multi-channel recorder!

Tried out the latest version of naudiodon that wasn’t working without portaudio installed on my mac, but unfortunately there is still a problem (but it’s different). Oh well, won’t stop me from working on this!

Been trying to get external recording working in Loop Drop with the segmented wave writer, but no data is flowing. Strange. Just tried the example and it works fine (pipe to to fs.createWriteStream). Wonder what is different about this way? Oh I’m missing .start(). Still occasionally getting “input overflow” error.

It is using a very small buffer size, can’t figure out how to increase it yet. Doesn’t look like you can, gonna try stream-chunker. That works!

Okay so tried recording multiple channels to one wave file but it’s not behaving quite right. The stream works fine, but maybe something is lazy in SegmentedWaveWriter. Gonna try uninterleaving the stream, and splitting into multiple files.

Trying to figure out an efficient way to deinterleave the stream and recombine into the correct channel mappings and discard unused. TO MANY MATH FOR MY BRAIN RIGHT NOW!

I’M DONE FOR THE DAY! Didn't manage to get a jam in :crying_cat_face: never mind. Some good research today.

Think tomorrow I should try setting up a worker thread to receive the buffers and then do the de-interleaving of the channels in the worker and post back buffered up chunks.

Join Scuttlebutt now