complex system for multi channel playback

R_Gol's icon

I would like to build a patch that will play different audio files base on a counter at multiple speeds.

I organized the needed instruction into a coll that will output the needed ones at each count.

All files will be named A to H and will be stored inside a folder called "audio"

I though the coll file should looks something like this:

1, A start 2000 0.1 0.5 0.7 1 1.1 1.2 1.8 2;
2, A pause 2000;
3, B start 3000 0.1 0.5 0.7 1 1.1 1.2 1.8 2;
4, B pause 5000;
5, A continue 2000 0.2 0.7 1 1.5 1.7 1.9 2;
6, A pause 2000;
7, C start 5000 0.1 0.5 0.7 1 1.1 1.2 1.8 2;
8, C pause 1000;
9, B continue 2000 1 1 1 1 1 1 1 1;
 

at count 1 - audio file A start to play from the beginning with 2000ms fade in time. each speaker will play the file at different rate that is specify after the fade in time.

at count 2 - audio file A will pause after 2000ms fade out time.

at count 3 - audio file B start to play from the beginning with 3000ms fade in time. each speaker will play the file at different rate that is specify after the fade in time.

at count 4 - audio file B will pause after 5000ms fade out time.

at count 5 - audio file A will continue to play from the position he was previously paused with 2000ms fade in time. each speaker will play the file at different rate that is specify after the fade in time.

at count 6 - audio file A will pause after 2000ms fade out time.

at count 7 - audio file C start to play from the beginning with 5000ms fade in time. each speaker will play the file at different rate that is specify after the fade in time.

at count 8 - audio file C will pause after 1000ms fade out time.

at count 9 - audio file B will continue to play from the position he was previously paused with 2000ms fade in time. each speaker will play the file at different rate that is specify after the fade in time.

How can I implement this fairly complex idea?

at least one problem that I can think of is how to store the paused time for audio file 'x' and make it continue from the same place when called again ?

I hope this above is understandable?

Max Patch
Copy patch and select New From Clipboard in Max.

edit: it might be that groove~ is not the right choice and better using sfplay~?

Source Audio's icon

use sfplay.

to keep elapsed times of each file,

collect that infos in another coll.

Before you stop current file, grab time and store.

example: store C 22345.1234

you recall that time when file needs to play using seek message.

actually you should allways use seek message to start or continue playback.

just start with prefilled coll having zero start times for all files.

A, 0;

B, 0;

C, 0;

.....

or better use as many sfplay~ instances as needed to cover all audio files

in poly~.

then each player can simply do what you tell it to.

R_Gol's icon

This what I cam with for the moment:

Max Patch
Copy patch and select New From Clipboard in Max.

how to implement the speeds rates into the mc.sfplay~ object?

the first two counts seems to work fine - fading in at count 1 and fade out at count 2. but count 3 won't start audio file B

Source Audio's icon

sorry, I don't think that is a good way to do this.

for that reason, I won't loose time trying to fix that.

If you accept suggestion with sfplay~ and poly~, ... ok

R_Gol's icon

Sure - sfplay~ and poly~ is fine

Source Audio's icon

you have to use resume instead of continue.

this is poly subpatch.

8play.maxpat
Max Patch


I added stop message, if you don't want it, remove it.

this is main patch.

Max Patch
Copy patch and select New From Clipboard in Max.

place both into same folder together with A.wav, B.wav etc


R_Gol's icon

Thanks!

few questions -

where should I place all the audio files?

how it is possible to make the audio file type dynamic (to work with either wav, mp3 aif etc) ?

each channel should be outputted to different dac output(1 to 8). I should change the poly sub patch like this?

Edit: another important question - what if I will have more then 8 files ?

(audio files are mono )

Source Audio's icon

Audio files go into same folder as patches.

if you want to load other files .... look into load-Audio subpatch.

replace file name with what you want.

Don't use mp3, they will anyway get converted to wav.

or use message like this for each target

target 1, file $1

adding 8 audio outputs is fine.

R_Gol's icon

there is something I don't understand if I have 12 audio files A - L and 8 outputs . How should I make this work? like this?

main patch:

poly patch: nothing to change?

Edit: seems to work with the changes I made

Source Audio's icon

You stated A - H which is 8 files .

now you need 12 poly instances

and 12 target messages.

NOT LIKE THIS :

OR THIS :

R_Gol's icon

12 poly instances with only 8 outputs.

This is right?

Source Audio's icon

that is ok now

Source Audio's icon

you can remove modout1 message.

it serves only for multichannel sfplay objects when

files with less channels are loaded.

R_Gol's icon

I wonder if this patch can let me play an audio file to speakers 1-2, another file to 3-5 and another to 6-8 ( just an example)

Or it is not an option in that configuration?

Source Audio's icon

No, with patches I posted it is not possible.

You did not request anything like that.

R_Gol's icon

This is something I understand later I need it to be possible in the patch

Source Audio's icon

you could insert thispoly~ object and get instance number.

then you can assign outlet(s) for audio output depending on

poly~ instance number.

but that will link only poly~ instance with output, NOT named file.

Your other option is to add another message into script, for example :

out nn

and route that as assignment in poly~.

for example out 1, out 2 etc.

out 1 would translate to output pair 1 & 2, if you want to use pairs.

One matrix~ with a bit of ramp time can serve as router for outputs.

R_Gol's icon

How can I add for each output different time for fade in and fade out?

so for example for fade in I will have coll looks like this:

1, A start 1000 2000 500 1000 2200 3000 500 1000 0.1 0.5 0.7 1 1.1 1.2 1.8 2;

2, A pause 100 2600 5000 2000 2200 300 5000 1000;

R_Gol's icon

Does it make sense?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

you will have to use 8 times the whole part which routes messages to each player,

and also provide 8 fading objects.

Start & resume message can be common, but pause and stop

will have to be executed after each fade out finishes.

means separate message for each player.

what is the fastest way to do so ?

Maybe make 1 instance , and then copy it 8 times ?

R_Gol's icon

This should work?

edit:

with instances:

Max Patch
Copy patch and select New From Clipboard in Max.

Edit 2. I change zl.slice 2 to zl.slice 9 and still not working.

What am I missing?

Source Audio's icon

You did not test anything, right ?

No chance for that to work.

Look precisely at your message from coll,

how do you use start, but then separate 8 fade in values ?

you keep zl.slice 2 in there, but message now has 1 + 8 fade values,

followed by 8 speed values.

even when that is fixed :

match start nn only passes 1st ( nn) value from the list

and so on....

R_Gol's icon

I fixed what you say:

Max Patch
Copy patch and select New From Clipboard in Max.

Still not working

Edit: It might seems just fine... Thank you!

R_Gol's icon

I think the fade in time is not working for the start message

Edit: All is working!

Source Audio's icon

You learn better whan you fix it yourself.

R_Gol's icon

Thanks. I also made instance for the fades part and change it to curve~ instead of line: