Hey!
I'm doing a project with one LDR sensor and I want it to trigger a different sample with different amount of light.
For the samples I've recorded one long file and i though I could just chop it up and make different amount of light trigger different bit of the long sample, and then crossfade it so it would be smooth.

I was wondering which way might be the best to go? I'm currently using Pure data.

how long is the long file? If it all fits in RAM, the process is pretty straightforward:

  • load it in an array with [soundfiler]
  • read the array with two [tabread~] objects and crossfade between them

If the file doesn't fit in RAM, then you'll need to use [readsf~] to read chunks of it. If you know in advance where in the file you'll start reading from, that's also kind of straightforward: prepare as many [readsf~] objects as there are possible start location, and send the [open( message to them. Whenever you need to start playing from a location, send a [1( message to the corresponding [readsf~] and crossfade it with the old one, to which you'll send a [0( and [open ( message as soon as the crossfade is completed, so that it becomes ready for the next play.

Thank you!!
do you have a photo or example of how it is supposed to be connected together?

the patch,
everything is working fine with the LDR!

No, I don't have such a patch ready to go, give it a try yourself and come back if you have issues

I've been trying this out (very new to this) but when I upload it as _main.pd on the Bela IDE it don't even show up so I don't know if i'm going the right direction with the patch... What could it be?

what is it that "don't even show up" ? The visualiser in the IDE will not display the array, but mostly everything else should be there. As that's just a visualisation, it won't affect the actual processing that Pd does on Bela.

A couple of issues with your code (unrelated to Bela) are:

  • no patch cord between read and soundfiler
  • the two multipliers before the dac~ have no arguments or cables into their right inlet, so they are multiplying by zero, effectively muting the outputs

It's probably best to make the patch work for on your computer first, emulating the analog input ([adc~ 3 4]) with a slider (with range 0 to 1) and make sure everything works before trying to run it on the board.