How to open and play (readsf~) multiple wav files at the same time?
-
read multiple wav using readsf
-
@Butahuruf You can have many [readsf~] objects in your patch.
You can maybe have too many (for an instant start) if you have a mechanical hard drive, but with an SSD you should not run into problems so quickly.
If you need them to start at the same time then obviously they all need to receive the start message at the same time.......
When they open their files they read part of the file into memory, so a small delay before the start message can help if you have many [readsf~] objects....... giving them all enough time to read from disk before starting.
David. -
@whale-av hi David, I've found this https://github.com/giuliomoro/dynamic-load-files-Pd do you how to create an instance of readsf~ ?
-
@Butahuruf It looks as though the patch is designed to create players..... depending on the number of files to be played......
The easiest way to do it is in a sub-patch as then you don't need to name the canvas, but you can do it in another patch.
You want to keep your main patch clean, because you will want to throw away those dynamically created players at some point, and that is hard when they are stored in the same patch.
You can easily clear the sub-patch at loadbang in case you saved your patch with them all still there (very likely while you are developing it).The dynamically created players will need arguments so they are all different, and so that they are all associated with just one audio file.
If you are not up to speed with arguments then read this........ https://forum.pdpatchrepo.info/topic/9774/pure-data-noob/4 ...... the text...... forget the picture.
For dynamic creation see this......... 0.all_msg.pd
(it seems to have gone awol from recent vanilla downloads)
You will see that you can dynamically put objects into the sub-patch...... and then connect them up.
You can do the same for your player patch.
You will need a counter to adjust x and y for each one or they will be put on top of each other.... although that doesn't really matter I suppose.
You won't need to connect them up for your case...... they can have receives and sends, catch~ throw~ etc inside....... but as I said at the beginning they will need arguments so that they are all different.
David.
Here............ try_this.zip
It didn't take long. -
@whale-av Let me explain more the patch I am looking for. I would like to create a sample midi player.
- Trigger them independently via MIDI keyboard
- As long as the key is pressed, the sound plays, and stopped when the key is released
- It allows multiple MIDI notes
This is the patch I made so far.
Archief.zipthe issues:
- it doesn't play multiple notes
- the first sound stop when another note is played
- it needs time to readsf
-
@Butahuruf One for each midi note I imagine.
...............................
Just seen your update. You will need a copy of your patch for each and every midi note.
Using [clone] is probably best then. For many uses it is easier than dynamic patching.
You will need to use the automatically assigned $1
Each clone copy is given a sequential number............so use [sel $1] in your patch to filter for a different midi note for each copy.
Don't forget to filter the velocity too.
Maybe [pack] note and velocity together and then filter.
David. -
@whale-av I'll try [clone] and [sel$1] thx!
-
@whale-av Hi David, I made this solution (and it works) instead of [clone]
I think there are more sophisticated solutions, can you have a look? Thx -
@Butahuruf There is nothing wrong with your patch....... except maybe the latest velocity is sent to all players?. I can't tell because [samplePlayer] is missing from your upload.
Probably it is ok because you have only the note banging in the velocity.I attempted to replicate it based on what I could see......
try_this.zip
You could get away with [poly 10] and only 10 clones, as you only (normally) have 10 digits.
But in case you ever put your whole forearm on the keyboard I set 16 voices as you did.
[poly] is set to steal voices, so when a note off has been received by a player it is released to be used again.
It might not work though...... midi is not really my subject.
David. -
@whale-av sorry samplePlayer.pd
-
@Butahuruf We are cross posting........
I posted a cleaner version above using [poly] and [clone]...... if it works as you wish?
It looks as though I guessed right.
David.
P.S. I think you will need [stripnote] to prevent the file playing again when a note off (0 velocity) comes in........ or something in the player to stop the player when that zero arrives. -
@whale-av I will have a look to your post
I use [sel 0] to prevent 0 velocity [notein] - right outlet [sel 0]
-
@whale-av said:
@Butahuruf We are cross posting........
I posted a cleaner version above using [poly] and [clone]...... if it works as you wish?
It looks as though I guessed right.
David.
P.S. I think you will need [stripnote] to prevent the file playing again when a note off (0 velocity) comes in........ or something in the player to stop the player when that zero arrives.I need a day or 2 to find your post about this. You post MANY!
-
@Butahuruf That is true.
This one.... https://forum.pdpatchrepo.info/uploads/files/1601810933635-try_this.zip
David. -
@whale-av Thank you very much David! this is great!
-
@whale-av Hi David I add [alt] to prevent 'double notes' on samplePlayer.pd
midi_sample_player.pd -
It is possible that due to an old hard disk, the computer may not be able to open and play (readsf ~) multiple wav files simultaneously. One solution would be to add an SSD that would make the work of the computer system easier. But that would involve too much cost. I donțt use the audio wav files format anymore because it is difficult to read and causes many problems. Instead, I decided to convert on https://convertr.org/wav-to-mp3 all the files in mp3 format supported by any application.
-
@Dorisma It will not be able to open multiple files at the exact same time, but it will probably not be noticeable.
If however they really need to be in sync......... for example if they are actually tracks of individual instruments that were all recorded at the same time in the same room......... that could cause some phase issues.A solution will be to open them all first. The first few seconds of every track will then be loaded to RAM (buffered).
Set a delay of a few milliseconds and then send the start message to all the instances at once.
All the instances of [readsf~] should then play them in sync.
David. -
@Dorisma said:
It is possible that due to an old hard disk, the computer may not be able to open and play (readsf ~) multiple wav files simultaneously. One solution would be to add an SSD that would make the work of the computer system easier. But that would involve too much cost. I donțt use the audio wav files format anymore because it is difficult to read and causes many problems. Instead, I decided to convert on https://convertr.org/wav-to- mp3 all the files in mp3 format supported by any application.
I'll follow all your steps, but still, I am facing some issues.
-
Dorisma said:
I don't use the audio wav files format anymore because it is difficult to read and causes many problems. Instead, I decided to convert on https://convertr.org/wav-to-mp3 all the files in mp3 format supported by any application.
I realize this is a couple years old comment now, but: [soundfiler] does not support mp3 format.
I'm not sure which audio programming environments do support MP3.
- Pd, no ("soundfiler read: /home/xxxxx/Music/23-0714-ambient-jam.mp3: unknown header format").
- Max/MSP, no ("can't open").
- SuperCollider, no ("File '/home/xxxxx/Music/23-0714-ambient-jam.mp3' could not be opened: Format not recognised.").
- I don't have ChucK or Reaktor, can't test those. Reaktor might support MP3 since it's a commercial product. ChucK... reference docs for SndBuf seem difficult to locate, so, I give up, I don't know.
So the approach of converting all WAVs to MP3 seems to be based on a mistaken assumption. For use with Pd, this is not the way to go.
hjh
-
ceammc lib have a [snd.file] object working like [soundfiler], that support mp3 and many more format
like AAC AIFF ALAC AU AVR CAF FLAC HTK IFF MACE3:1 MAC6:1 MAT4 MAT5 MP3 MP4 MPC OGG PAF PVF RAW RF64 SD2 SDS SF VOC W64 WAV WAVEX WVE XI.