I find that the Pd command line functionality is broken in many  
versions of Pd for OSX.  (at least i can't get it to work)
The latest Pd extended (0.40.3) DOES seem to work for the command line  
though, which is good news.

However, once you save preferences, they are saved into ~/Library/ 
Preferences/org.puredata.pd.plist and will be picked up by every Pd  
that you launch - e.g. the plain Pd versions.

So saving preferences only works if you only ever need one Pd setup.   
This is fine if you only use the full Pd extended.

For my purposes, I like to write Pd preferences directly into the  
preferences file and then move it into the Pd.app bundle.  This works  
for every Pd version, and if you never actually save preferences from  
within Pd, you can run different Pd.app bundles for different needs.   
OR, if you do save preferences, you can just re-move the  
org.puredata.pd.plist back into the appropriate bundle to restore  
separate preferences for different Pd.app bundles.

I went so far as writing a bash script that downloads Pd, writes  
preferences, moves them into the bundle, copies any libraries,  
abstractions or patches I want into the bundle, and renames the bundle  
to a custom name.

I think this is similar result to Hans' standalone app generator,  
though I haven't checked out how that works.  (i think it's a build  
process, more than plain script).

I've copied my template script below in case anyone wants to use it.   
You would have to customise it to your needs though.  Also, if you  
want to start a given patch at runtime, there are some limitations  
with moving the .app bundle to different locations.

cheers
Nick

http://soundsorange.net



here's the script
---------------------------------------------------
#!/bin/sh

current_dir=`pwd`
date_time=`date "+20%y%m%d_%Hh%M"`
echo
echo - current directory is:
echo ${current_dir}

# edit CUSTOM_PD_NAME to name your new customised Pd .app bundle
CUSTOM_PD_NAME="Pd_Custom.app"
## edit PD_PATCH to name patch to load on starting the Pd.
#PD_PATCH="start_patch.pd"
## edit PD_PATCH_DIR to name patch directory within custom Pd bundle.
#PD_PATCH_DIR="custompath/patches"

# edit PD_INST_ORIGINAL to match Pd .app version and location
PD_INST_ORIGINAL="${current_dir}/Pd-0.41-4.app"
PD_INST="${current_dir}/${CUSTOM_PD_NAME}"
PD_BUNDLE_PATCH_DIR="/Contents/Resources/${PD_PATCH_DIR}"
echo sudo cp ${current_dir}/${PD_PATCH} ${PD_INST_ORIGINAL}$ 
{PD_BUNDLE_PATCH_DIR}


## NOTE - in bash script file testing, spaces are important!
## NOTE also -f tests specifically for file, -e for existance of  
anything (eg app bundle)
## example:
#if [ -f testfilename ]
#then
#  echo testfilename exists!
#fi
#if [ ! -f testfilename ]
#then
#  echo testfilename doesn't exist!
#fi

# clean up previous raw Pd app
if [ -e $PD_INST_ORIGINAL ]
then
        echo - Delete the old vanilla Pd app just in case it has been modified.
        sudo rm -rf $PD_INST_ORIGINAL
else
        echo - No old Pd app bundle exists.
fi

# clean up previous customised Pd app
if [ -e $PD_INST ]
then
        echo - Delete the existing customised Pd in case it has been modified.
        sudo rm -rf $PD_INST
else
        echo - No existing customised Pd app bundle exists.
fi

# download new Pd if needed (if it doesn't already exist)
if [ ! -e pd-0.41-4.mac.tar.gz ]
then
        echo - Downloading fresh vanilla Pd.
        curl -o pd-0.41-4.mac.tar.gz 
http://crca.ucsd.edu/~msp/Software/pd-0.41-4.mac.tar.gz
else
        echo - No need to download fresh vanilla Pd.
fi

# unzip the pd vanilla app that was either just downloaded or already  
existed
echo - Untar the fresh vanilla Pd.
tar -zxf pd-0.41-4.mac.tar.gz

# backup any old plist as before, and then remove it
if [ -e ~/Library/Preferences/org.puredata.pd.plist ]
then
        echo - Backing up old org.puredata.pd.plist and deleting it ready for  
new one.
        echo - Backup file is: ~/Library/Preferences/org.puredata.pd.backup_$ 
{date_time}.plist
        cp ~/Library/Preferences/org.puredata.pd.plist ~/Library/Preferences/ 
org.puredata.pd.backup_${date_time}.plist
        rm ~/Library/Preferences/org.puredata.pd.plist
fi

# copy any libraries you wish from /copy_to_externs/ directory into Pd  
bundle extras...
echo - Copying externals and patches into the Pd app bundle.
cp -R ${current_dir}/copy_to_externs/* ${PD_INST_ORIGINAL}/Contents/ 
Resources/extra/
# make directory for patches
sudo mkdir -p ${PD_INST_ORIGINAL}${PD_BUNDLE_PATCH_DIR}
# copy custom patches into this directory
sudo cp ${current_dir}/${PD_PATCH} ${PD_INST_ORIGINAL}$ 
{PD_BUNDLE_PATCH_DIR}

echo - Preparing permissions in the Pd app bundle.
# prepare file and directory permissions
sudo chmod -R 0755 ${PD_INST_ORIGINAL}/Contents/Resources/extra/*
sudo chmod -R 0744 ${PD_INST_ORIGINAL}/Contents/Resources/extra/*.pd
sudo chmod -R 0755 ${PD_INST_ORIGINAL}${PD_BUNDLE_PATCH_DIR}/*
sudo chmod -R 0744 ${PD_INST_ORIGINAL}${PD_BUNDLE_PATCH_DIR}/*.pd

# create the new plist below. Make sure to get npath and nloadlib  
numbers correct
echo - Writing new Pd plist file.
defaults write org.puredata.pd audioapi 4
defaults write org.puredata.pd audiobuf 50
# audiodev number num_channels (eg audioindev1 "0 2")
defaults write org.puredata.pd audioindev1 "0 2"
defaults write org.puredata.pd audiooutdev1 "0 2"
defaults write org.puredata.pd callback 0
defaults write org.puredata.pd defeatrt 0
# make the customised Pd open the Pd patch on startup - IMPOSSIBLE!   
except for a fixed directory, which will break if the .app is moved
#defaults write org.puredata.pd flags "${PD_AUDIO} -open ${PD_PATCH}"
defaults write org.puredata.pd flags ""
defaults write org.puredata.pd nloadlib 0
#defaults write org.puredata.pd loadlib1 iemlib1
defaults write org.puredata.pd noaudioin False
defaults write org.puredata.pd naudioout False
defaults write org.puredata.pd nomidiin True
defaults write org.puredata.pd nomidiout True
defaults write org.puredata.pd npath 0
## make sure the custom path is in the Pd path - IMPOSSIBLE!  except  
for a fixed directory, which will break if the .app is moved
#defaults write org.puredata.pd path1 "../${PD_PATCH_DIR}"
defaults write org.puredata.pd rate 44100

# move the new plist into the .app and remove it
if [ -e ~/Library/Preferences/org.puredata.pd.plist ]
then
        echo - Moving new plist file into the vanilla Pd app bundle then  
deleting it from Library.
        sudo cp ~/Library/Preferences/org.puredata.pd.plist $ 
{PD_INST_ORIGINAL}/Contents/org.puredata.pd.plist
        sudo rm ~/Library/Preferences/org.puredata.pd.plist
        sudo chmod 0755  ${PD_INST_ORIGINAL}/Contents/org.puredata.pd.plist
else
        echo - Looks like you didnt make a new pd.plist so there isnt one to  
copy to the new Pd app bundle.
fi

# last thing - move and rename the Pd .app
echo - Renaming the new customised Pd app bundle.
sudo mv ${PD_INST_ORIGINAL} ${PD_INST}

echo - Finished!
echo




On Oct 28, 2008, at 2:25 AM, Simon Wise wrote:

>
> On 28 Oct 2008, at 4:21 AM, Gal Chris wrote:
>
>> Hello
>>
>> somebody nows how tomake a script in OSX to load a PD patch
>> selecting a specific sound decive ( MOTU sound card) and 8
>> channells?....
>>
>> When I start PD manually it select by default the Imac soundcard so
>> I have to select the device (MOTU) in media>portaudio manually ....
>>
>> I need to make a script with a especific configuration because is
>> for a sound installation
>
> try something like:
>
> /Applications/Pd.app/Contents/Resources/bin/pd -audiodev 2
>
> depending of course on where your Pd is, and what it is called.
>
> you could save that line in a .command file.
>
> alternatively save the CL flags in your Pd startup preferences,
> remember to 'apply' then 'save all settings', then restart pd.
>
> to find out which device numbers correspond to which audio devices
> use -listdev as a startup flag and look at the console output. To
> find out available startup flags, for more control of devices
> channels etc, try:
>
> /Applications/Pd.app/Contents/Resources/bin/pd -help
>
> in Terminal.
>
> When all is set, make sure the MOTU is plugged in before Pd is
> started. 'Open at Login' in the dock can be useful if you want
> automated launch, as can 'restart after power failure' hidden away in
> 'options'
> in 'energy saver' preference panel
>
> simon
>
> _______________________________________________
> Pd-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list


_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to