Record audio to a folder relative to patch?
Let’s say I’ve got a patch called ‘foo.maxpat’ saved in a folder called ‘bar’, then I make a subfolder called ‘audio’. How can I get an sfrecord~ object in foo.maxpat to record into the ‘audio’ folder, so that I end up with ‘bar/audio/myfile.aif’? In such a way that I can move the whole ‘bar’ folder anywhere and it still works? Max 5, OSX.
Maybe look to the "path" message to [thispatcher], and some sprintf to create the complete filepath (adding on audio/myfile.aif….also you can put numbers into the filename with %ld inside sprintf). Watch for spaces in the path, it needs to be a single symbol. It takes a bit of trial and error but can be done.
[opendialog fold] and the [dropfolder] can also work, but the other method can be done automatically.
The path message to [thispatcher] does sound like the right approach here, but you should also know about Jasch’s [getpaths] object. Here’s an example patch using both.
----------begin_max5_patcher---------- 1076.3oc0Ys0iahCF84jeEVTMukMEysP59z9GXWsZebUUjC3j3V.ivloyLUs +1WeAxsMPrSPzIZjLxewXe7wmuKl46Sm3rl9Bl4.9D3eASl78oSlnLIMLoo+ DmbzKIYHlZXNE3uQW+EmY5ehiegqLyALv5VqE04jhLLW8FvFikHdxNRw1UU3 DtdEiil6NC.iBjO78ksdtycAet4UHop4Vrd+lWT6jugVvKP4X0O8GUDT1QKK sl2ttdMV0l3uVh0KpiyLfyZTwVm8qibJYj2TC.5M2UZ8GSmJalcezxaYfuPI EWjX75lX77BUjQ3R4i.XuLS3fxLiAqvJqHE7MfmHx+VoeL+anmuHOEccdJVw Svv39HJXfsDErShZHIobLig1h++tTjb7LPJhiuQ4CbohVhTNVv3KyJwuOIkN TNcxFvqKR7hNvFcoQ7skM76hMxHLtzep8oPvOnDTBMOGKlyyYnsXN3YTEgVy .BxXGCrohlC9q+wZZK1UwWMtVt8FCxZdycLB8xxHIX.zd2GU.Ws2S3hd23tO bAeSnEanU4RsAPLd.ZMilUeCtU5jSPOiDHvAkmFZmI7aonjeZqNAFozIAMYo CaauXxmkc3GbCnkS2tMy5yqPUUVAd6Om5ISYrkg90mG2etOSYdcgiAPkuo+R u9RvACenxvUVgKwEo.pn81pm1eg+7vYf3vdOh8dnXk1JFYuJgD3I1GQ0oD5G ehcaRGenQULBeeRRck6WVqAHotpR7ipj+1JfVnJNxWQJK6sPIn6uvL9cUwbm a4dzC9QG1x9A8EHI5gxiguivTaWbksp.MknK7S21kJHXjp9owLC8b63+veJe iS1j.meW17g+V1JBgpsLDokNb8i57RqqlL16HE1x9TXKdepvpEAapsUDA0We Pusgt8Wuw9qOH2BMeNpS1A20UwjUmL6bIVFZMNKQbAgud7FoCgGgiyafkyNp .JhoZlrohR466TyvUJf1ZP7Vk66fJKEqFhSnEr8FSoIR1kyNYRVkQVWgpdcu wy6mhYekSu3buhUWVRqNEUqt1.Nr9IHg2zYv4LanrrUWb2H+AMTIxSwOObQy D2pUcYV6u6O7PTrqbUtGqBh1H1jzpzeda0HFHJ7QTiXTueYwgq5GFYag3kLg WTiQH3KN+yRq1KR6mRVLZcUR65zdUSvg8ivUgSJTB0iGTzICZGIMEWbbUJ4j zRJof2.BuHEeACUr2xv8c5PjaLXiL.rPncfcHvD7JXJ1NHAcWpnrkZAmnPq1 d2IXCL.q1dXemPR9clM6LENdXxDmB4cBGQdx2jitvQkl7MIzQ335MFZxIWvn hoXCfj+35yYjXZTgzBSzRVlERDvTl0VE8zy2ssychTSxAMtBryhD0gn2xXC5 r1AtAyWHepynq6duv0HezwkAie2AI4+qjq6iNxXxDmT26.RhN+X5+ADUI7dC -----------end_max5_patcher-----------
Thanks for the replies and the example patch; that makes sense. I thought I was maybe missing an easier way…
I think that [sprintf symout %s/audio/%s] should be [sprintf symout %saudio/%s] since there is already a slash at the end of the path.
So, this is brilliant and useful. What i can’t quite figure out is how to do a variation this that would be exceedingly helpful.
In the case where i am munging a soundfile (off the disk or loaded into a buffer) I like to know the sound file that was used and usually include that in the name.
So if the source is a file called foo-Eb_25.aif then I would get a file in the audio directory called:
or some such. The reason is that my names are occasionally meaningful and contain information about what kind of musical gesture it is and pitch info.
I guess you can bang info~ and then used the last outlet of that and somehow concat that into the name after stripping the extension, but i can’t quite get that to work.
One other idea, not sure if it can work, but if you tell sfrecord~ (or any object which can do a "write file" kind of command) simply to save with a filename, it goes into the main Max 5 application folder, at least on my XP machine here. If there was a way to tell Max to change this default location to be something different—like the output of [thispatcher] "path"—then perhaps all subsequent file-writing could go to that folder? It would eliminate all the sprintf-ing. :)
I was testing some save features awhile back and my examples were saving somewhere, but I couldn’t figure out where they were going…thought it would be the patch’s folder, but I suppose the Max 5 App folder makes sense too. Anyway, no big deal.
You’re right about that extra slash in the path, I spotted that slip too.
As to where files are saved by default; into the application folder does seem a bit daft. I’m trying to remember how this works on Pd; I might have thought a better default location might have been into the same folder as the patch? Isn’t that the way it is in Pd?
Here you go.
----------begin_max5_patcher---------- 1419.3oc0Zs0iahCE94L+JrRUkZqxlw1Xt08oUaeXeYuoU6ScqhHDmD2BXDF laUc9su9RfIY1.wjjxNYhBL1Xve9ymyweGb95UiFOmeGULF7dvGAiF80qFMR WkphQaJOZbZzcwIQBcyFGySSoYkimXtVI8tRc8hxBVNPVhlIX7r5qmUkxxRn k5aFsox7nx30rrUyJnwklN2C5NENAfC7UmBBzEfSgfOs4dXKzcCe9m+ALt9o ujmUlEkR0W5mJXQIa0u7px5NFtU6ErGzsGgmBU09sqtRcXhki+L5sRL7eF9O j.nwrDA.s2QNt8QtKROxcPNSQHRX3DfqeWidGReG80ctopx6yoldd73IxuM8 w2OxofthdWN3MSe2aey+H+a5GUGu8Su6s80LgDhl5CwNPjxVwaJLj.ccm.PH TWbVXeoL2Nors+dNouTpPDshtG9KOIJl1WKKEYIIETPn5jKzTnEepdSQnVon Avhhksj+HXdRz5iwBRYo3h0zgzqysiHM98kUBZiUVlviJUVLILg9bSE17OCA mNuZ4RZwowpHO0IeRmguOeAvZ3m4QYqFBNpDH.y6K4ffF+PeseniSmji2YM5 9PwKxk+9Lmk02HTXrwrwWuhGoyX3X2Kt08D4ErrxkfWyTelYNM81na1KO4cP dxAp4IjamxiPjWlgxaa0sRVJcBXQTI8XMePZZwyoqE3BtnVeqU1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lacgSct1wFuzAk7rwG0Y XCkYkO5vZh4XiIl6fCIjMPBMXPxJgEdCqwjmEXJnePBYj7hg5zekBFaJcpf0 lDY5KAhCzRxP9lelQlEFzk1AsxBe6p+0si0xQ -----------end_max5_patcher-----------
Thanks for that. I was sniffing in the right corners, but i never would have thunk to use regexp. Fantastic.
Any special reason to use Jasch’s [getpaths]?
The [getpaths] object is useful when you want to find various paths on the user’s system. You can do things with that object that can not be done with [thispatcher], such as save to the home directory of whatever machine you’re using. But it’s Mac only.
Forums > MaxMSP