Loading resources in gen~

,

Ok, if you upload somewhere that WAV file and both exports, I’ll have something to look at. Is it only working if you set it to length - 1 or any number smaller than length or even 0?

any number as long as it is 1 sample smaller. I used audacity and maxmsp to get the sample number so I am trusting their count.
Other than that…wow this is working!!!

not sure about 32bit pcm file but whatever.
I see there is multichannel stuff too - that will be insane.

https://a.tmp.ninja/rDwcKhhp.wav dunno why this temp host renamed the file but thats the data file im using at the moment

ok more weird stuff is happening - i got a loop thats 84000 samples long - only half of it will play if use that as the data length. adjusting the size doesnt really fix it. Uploading a wav file that is twice as long will make the playback work - but if you set data length to 168000 then half of that one will play and the rest will be silence. Thats insane

ok one more experiment was a sample 362464 samples long and it only worked if data was set to 362463 . Hopefully these are useful clues.

@antisvin just a headsup - figured out why i was having those weird half playback issues - it is because the samples were STEREO. So it seems that causes some weirdness with playback and you end up with half of the wav being played back, and half of it is empty silence. Maybe something odd with channel assignment.

other than that all seems pretty sweet so far.

I’ve found a suspicious place that caused gen~ to erase buffer during reset (which happens when file is loaded) and the old size is the same as new size. In this case, old size is full WAV file size and new size is what you set in [data ...] arguments. I think that normally people would allocate a buffer larger than sample and playback speed won’t depend on sample size but rather sampling rate alone and this condition is not triggered, even though it won’t make sense with something like a wavetable. Anyway, I’ve disabled the code that cleared the buffer in my branch, but I’m not sure if it wasn’t needed for anything else in gen~.

Regarding stereo and multichannel samples, I don’t know if they work correctly as the patch you’ve sent me only plays 1 channel. But they do load and at least the first channel is played, so I would expect them to work.

1 Like

Ah interesting! I’ll play around with it and make a better example with some multi channel wavs. It is very easy to make them i’ve discovered. As for data - since its a buffer you name and allocate space to and then fill it up with whatever, I was wondering how you are approaching it with Owl.

If a resource name exists with the name of the data buffer, then the resource file is used? and if not, then its just empty data that you name and use inside the gen patch I guess? I didn’t study your code but will take a look so no rush.

With current branch, resource data is loaded by file name. I’m not 100% sure what would happen if no resource exists with a given name, but I would expect the patch to fail.

OK cool, will test it. I’ve used data successfully before (as gen~ intends you to use it…to poke and peek information from a data object that you allocate space to at bootup). Data is always cleared when a patch runs, and then you populate it (which of course you can do as part of bootup). This is actually something im learning now while making a lich patch thats also a max4live device - how do you save the data with the max4live/ableton live set. For the modular Lich implementation of the patch im not gonna dig into saving data …although an interesting and not easy project for someone with programming experience :slight_smile: