Bitcrush Audio Effect Speed Issues

I've recently created this block bitcrush sound which works well, but it's really slow.

Here's the script for this reporter:
bitcrush sound script
I still want to keep the sound at 48kHz, or else it'll sound muffled and low-quality, and the idea is to keep repeating samples for the amount it should.

Is there any way to rewrite this script to make it faster?

Of course, feel free to drag the code into the Snap! playground to test the script by yourself.

I expect that some combination of RESHAPE, COLUMNS, and FLATTEN can do what you want.

Yes, but reshape, with a smaller sample size, just duplicates the samples, so it wouldn't help. Yes it would!

reshape - smaller sample size
As reshape, with a larger sample size, will crop the samples.
reshape - larger sample size

Flatten won't do much help, since I made the sound mono beforehand
mono sound script
to make the block quicker.

Finally, for columns, I just think it's a little bit unnecessary.

I wonder if there's some "stretch list" block that could come in handy?
[scratchblocks]stretch (list [1] [2] @addInput::list) to (4) @addInput::list reporter[/scratchblocks]

i'm guessing the performance issue might be that you're making the list longer repeatedly. maybe try starting by creating the list with the correct length, and then setting all the samples either with a loop or map.

Seems like it would be a major help. If it works, I will mark this as a solution. Thanks!

Protip: you can use @</span>addInput in scratchblocks to add the little arrow.

Like this:
[scratchblocks]
(stretch (list[1][2] @addInput ::list) to(4)⋮@addInput ::list)
[/scratchblocks]

(I don't know how to make this work, though...)

I'm having a bit of trouble using your block

In the code - its looks like mono-samp is set to a number....

and as I'm typing this - I realise that your expecting the sound to be in stereo and mine is a mono recording from my webcam :slight_smile:

Isn't duplicating samples what you're trying to do?

Sorry! Here's the updated version.
It converts a stereo sound to mono with my block [scratchblocks]convert sound [sound v] to mono:: sound reporter[/scratchblocks] and then it does stuff from there.
stuff
The problem is that it's adding the items, and not the lists, becuase the sound is mono, so there are no lists to combine, so it adds all items.

Yeah, that was before I realised you could reshape a scalar. I've updated it, and it sort of improved, but it's still slow.
ACTUAL UPDATED BLOCK! I've made some mistakes. :(


Topic closed...

So after messing around, I tried to make a better bitcrush block, and I made a mapping block, but it takes significantly longer - about 4 times longer than the first prototype I made - so it isn't helpful.

A little screenshot of this

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.