Hi there,
PD is amazing it can do almost anything. If I sit down and think about it, I can work out a way to build almost any machine I want, its the perfect piece of software for a power-hungry control-freak audio nut like myself who (during the early 90's) was dreaming up all kinds of impossible audio ideas (back then I knew nothing about computer programming, and even if I did the ideas would still have taken a very long time to implement)...
as soon as someone showed me MAX/MSP and PD I was over the moon!
Over the past few months i've been slowly implementing some of my "dream, impossible audio ideas" but this one still eludes me.
Imagine this scenario:
I have a harddisk full of audio recordings, I wish PD to play a random selection of these, a bit like a traditional CD player set to "random" mode, or Ipod shuffle.
A CD/Ipod shuffle will play the whole track, some of the recordings on the disk are several hours long, I wish PD to select (for example) 16 files out of the list of thousands, seek to a random position in the file and play a 1 second snip from each.
Imagine the posibilities of rhythmic patterns that could be created if this simple process was then automated and triggered rhythmicly with a sequencer!
------
I have a copy of PureData extended 0.37 and at the moment have a small self made sequencer controlling 16 xgroove~ objects playing new random-seek segments from 16 arrays.
but the "select 16 new files to go into the arrays" process is entirely laborious and MANUAL.
Its got to the point now where I need to ask someone (you guys!) if there is a way to implement this in PD?
-
Getting a directory listing into PD
-
sounds pretty cool--plunderific, if you will.
here's a thought.
it's fairly easy to compile a text file of every audio file on your computer (atleast with windows, and probably linux...not sure about mac). something like this should do the trick at the windows (dos) command prompt:
dir /s /b *.wav > audiofiles.txt
then use a text editor (like notepad--something with good find and replace tools)) to clean it up and format it.
once you have the file ready to go, you'll get it into Pd using the textfile object.
if you need some ideas about randomizing things let me know, because i have a few.
with a method like this, you would need to update the textfile any time you added audio. but that still beats having to load files manually. let me know if you need help with any of the specifics. i didn't include too many specifics because you sound like you have a decent grasp of Pd. -
..for 2 hour files, you don't want to put them into arrays..cos that'll take you forever...
just use [readsf~]
(or [sfread~] or [sfplay~] or whatever the equivalent is on your system)
it will take an offset as a starting command, and will play the file directly from your hard disk.
zac suggests [textfile], but i would maybe lean towards [qlist] or even the super dooper [msgfile] external.
also, if your system will run yves' [playlist] external, you can use that to load files by sending it "seek $1" messgages. i have made exactly the type of patch you described by using that.
get the [playlist] external here (unfortunately it's only for osX and Linux):
http://ydegoyon.free.fr/software.html -
thanks for the information guys, i feel like a bit of an idiot given that the answer lies in the very OBVIOUS [textfile] object! ;o) I was looking for objects and externs that handled directory listings directly, but strangely I did not stumble across [playlist] until just now.
I'll begin work later this week, and let you know how I get on.
Zac: re randomness - i'll probably be using the [msgfile] external with plain old [random] seeks to various lines in the text file, did you a different way in mind?
I'm a bit worried that [readsf~] wont do looping like [xgroove~] will, and that it requires acurately timed SEEK, START and STOP commands to be sent in order to play snippets rather than entire files - this could mean a lot of objects arranged with suitable event delays just to get the timing right, but i`m sure i`ll work something out.
Hardoff: you say you've built a patch already - that was fast work sir!
I didn't mean this post to be a "someone build it for me" request - and I still don't mean that now - but would you let me see your implementation later? (I wanna try building my own first, but i'm very curious to see yours!) -
zac: i've uploaded my implementation of the "randomly select a new line from the text file" here... it requires the [msgfile] external and a file called input.txt
http://www.zenpho.co.uk/zenpho-textselect.pd -
playlist is your friend.
it's the only external i couldn't be without
i'l show you my patch if you show me yours ...(worst nerd joke EVER) -
thank you thank you thank you for all your help guys!
i've uploaded the full thing (its very messy):
[url=http://www.zenpho.co.uk/zenpho-textselect-andplay.pd ]http://www.zenpho.co.uk/zenpho-textselect-andplay.pd
i`ll formally publicise this patch after i've tidyed it up, then i`ll upload a small mp3 into the "output - feed your ears" section of this forum. -
_Zac: re randomness - i'll probably be using the [msgfile] external with plain old [random] seeks to various lines in the text file, did you a different way in mind?
_
what you did works fine. pretty similar to what i might have done. i am glad you knew about the [msgfile] extern. i bet that makes things a little easier. looks good. i'm curious to hear how it sounds.
-zac -
ha ha..that's so nice to put in the comment about zac and me ) welcome to antibling, and i hope that you stay for a while.
there is an external called [filesize] which accepts a message in the form of
[symbol c:/audio/rocknroll.wav], and outputs the size of the file in bytes.
check if you've already got it cos i just googled for it with no luck. if you don't have it, i'll email it 2 you or post it here or something.
once you've got that, you can just write all the filesizes into a table, and read the filesize values with the same [random] seek number you're using to get your audiofile -
there is an external called [filesize] which accepts a message in the form of
[symbol c:/audio/rocknroll.wav], and outputs the size of the file in bytes.
check if you've already got it cos i just googled for it with no luck
It's in CVS Pd externals as part of the ext13 library, but you can build it as an individual object if you use the unified build system.
A web search for pd filesize.dll will find a Windows version. -
today i just realised:
arrays can read from and write to textfiles. this is really convenient for making sequences and stuff. i find that arrays are much easier to work with than [qlist] or [textfile] or even [msgfile]