public static List createDefaults( Preferences mainPrefs, double lastVersion )
{
File f;
String value;
Preferences childPrefs, childPrefs2;
final String fs = File.separator;
final boolean isMacOS = System.getProperty( "os.name" ).indexOf( "Mac OS" ) >= 0;
final boolean isWindows = System.getProperty( "os.name" ).indexOf( "Windows" ) >= 0;
final List warnings = new ArrayList();
putDontOverwrite( IOUtil.getUserPrefs(), IOUtil.KEY_TEMPDIR, System.getProperty( "java.io.tmpdir" ));
// general
putDontOverwrite( mainPrefs, KEY_LOOKANDFEEL, UIManager.getSystemLookAndFeelClassName() );
putBooleanDontOverwrite( mainPrefs, CoverGrowBox.KEY_INTRUDINGSIZE, isMacOS );
putBooleanDontOverwrite( mainPrefs, KEY_INSERTIONFOLLOWSPLAY, true );
putBooleanDontOverwrite( mainPrefs, KEY_VIEWCHANMETERS , true );
putBooleanDontOverwrite( mainPrefs, KEY_VIEWMARKERS , true );
putBooleanDontOverwrite( mainPrefs, KEY_VIEWNULLLINIE , true );
putBooleanDontOverwrite( mainPrefs, KEY_VIEWVERTICALRULERS, true );
putBooleanDontOverwrite( mainPrefs, KEY_CATCH, true );
putIntDontOverwrite( mainPrefs, KEY_TIMEUNITS, TIME_MINSECS );
putIntDontOverwrite( mainPrefs, KEY_VERTSCALE, VSCALE_AMP_LIN );
// audio
childPrefs = mainPrefs.node( NODE_AUDIO );
childPrefs.remove( "boottimeout" ); // not used any more
childPrefs.remove( "audiodevice" ); // not used any more
childPrefs.remove( "audioinputs" ); // not used any more
childPrefs.remove( "audiooutputs" ); // not used any more
putDontOverwrite( childPrefs, KEY_AUTOPLAYFROMFINDER, AUTOPLAYFROMFINDER_NONE );
// audioboxes
value = AudioBoxConfig.ID_DEFAULT;
putDontOverwrite( childPrefs, KEY_AUDIOBOX, value );
try {
if( !childPrefs.nodeExists( NODE_AUDIOBOXES )) {
childPrefs2 = childPrefs.node( NODE_AUDIOBOXES );
new AudioBoxConfig( value, "Default", 8, 8, true ).toPrefs( childPrefs2.node( value ));
}
}
catch( BackingStoreException e1 ) {
warnings.add( e1.toString() );
}
putDontOverwrite( childPrefs, KEY_AUDIORATE, new Param( 0, ParamSpace.FREQ | ParamSpace.HERTZ ).toString() );
putDontOverwrite( childPrefs, KEY_AUDIOBUSSES, new Param( 256, ParamSpace.NONE ).toString() );
putDontOverwrite( childPrefs, KEY_SCMEMSIZE, new Param( 8, ParamSpace.NONE ).toString() );
putDontOverwrite( childPrefs, KEY_SCBLOCKSIZE, new Param( 64, ParamSpace.NONE ).toString() );
putBooleanDontOverwrite( childPrefs, KEY_SCRENDEZVOUS, true );
// putBooleanDontOverwrite( childPrefs, KEY_AUTOBOOT, false );
// outputconfigs
value = "out1to2";
putDontOverwrite( childPrefs, KEY_OUTPUTCONFIG, value );
try {
if( !childPrefs.nodeExists( NODE_OUTPUTCONFIGS )) {
childPrefs2 = childPrefs.node( NODE_OUTPUTCONFIGS );
new RoutingConfig( value, "Out 1-2", new int[] { 0, 1 }, -90f ).toPrefs(
childPrefs2.node( value ));
value = "out1to8";
new RoutingConfig( value, "Out 1-8", new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, -45f ).toPrefs(
childPrefs2.node( value ));
// // ok dis wan is rather for demonstration purpose
// new RoutingConfig( value, 2, new int[] { 1, 0 }, -90f ).toPrefs(
// childPrefs2.node( "Reversed Stereo" ));
}
}
catch( BackingStoreException e1 ) {
warnings.add( e1.toString() );
}
// inputconfigs
try {
if( !childPrefs.nodeExists( NODE_INPUTCONFIGS )) {
childPrefs2 = childPrefs.node( NODE_INPUTCONFIGS );
value = "in1";
new RoutingConfig( value, "In 1", new int[] { 0 }, 0f ).toPrefs(
childPrefs2.node( value ));
value = "in1to2";
new RoutingConfig( value, "In 1-2", new int[] { 0, 1 }, 0f ).toPrefs(
childPrefs2.node( value ));
value = "in1to8";
new RoutingConfig( value, "In 1-8", new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0f ).toPrefs(
childPrefs2.node( value ));
// // ok dis wan is rather for demonstration purpose
// new RoutingConfig( value, 2, new int[] { 1, 0 }, -90f ).toPrefs(
// childPrefs2.node( "Reversed Stereo" ));
}
}
catch( BackingStoreException e1 ) {
warnings.add( e1.toString() );
}
// try {
// value = InetAddress.getLocalHost().getHostName() + ":57110";
// }
// catch( IOException e1 ) {
// System.err.println( e1.toString() );
// value = "127.0.0.1:57109"; // not 57110 which may interfere with a running copy of sclang
// }
// putDontOverwrite( childPrefs, KEY_SUPERCOLLIDEROSC, value );
putDontOverwrite( childPrefs, KEY_SCPROTOCOL, OSCChannel.TCP );
putDontOverwrite( childPrefs, KEY_SCPORT, new Param( 0, ParamSpace.NONE | ParamSpace.ABS ).toString() );
// sc app
if( childPrefs.get( KEY_SUPERCOLLIDERAPP, null ) == null ) {
f = findFile( isWindows ? "scsynth.exe" : "scsynth", new String[] {
fs + "Applications" + fs + "SuperCollider_f",
fs + "Applications" + fs + "SuperCollider",
fs + "usr" + fs + "local" + fs + "bin",
fs + "usr" + fs + "bin",
"C:\\Program Files\\SuperCollider_f",
"C:\\Program Files\\PsyCollider"
});
if( f == null ) {
if( isMacOS ) {
try {
f = MRJAdapter.findApplication( "SCjm" );
if( f != null ) f = new File( f.getParentFile(), "scsynth" );
}
catch( IOException e1 ) { /* ignore */ }
}
if( f == null ) {
warnings.add( AbstractApplication.getApplication().getResourceString( "errSCSynthAppNotFound" ));
}
}
if( f != null ) putDontOverwrite( childPrefs, KEY_SUPERCOLLIDERAPP, f.getAbsolutePath() );
}
value = childPrefs.get( KEY_SUPERCOLLIDERAPP, null );
putBooleanDontOverwrite( childPrefs, KEY_AUTOBOOT, (value != null) && new File( value ).isFile() );
// OSC
childPrefs = OSCRoot.getInstance().getPreferences();
if( childPrefs.get( OSCGUI.KEY_SWINGAPP, null ) == null ) {
final String[] folders = new String[ value == null ? 2 : 4 ];
folders[ 0 ] = fs + "Applications" + fs + "SwingOSC";
folders[ 1 ] = "C:\\Program Files\\SwingOSC";
if( value != null ) {
folders[ 2 ] = new File( value ).getParentFile().getAbsolutePath();
folders[ 3 ] = new File( new File( new File( value ).getParentFile(), "SwingOSC" ), "build" ).getAbsolutePath();
}
f = findFile( "SwingOSC.jar", folders );
// if( f == null ) {
// warnings.add( AbstractApplication.getApplication().getResourceString( "errSCSynthAppNotFound" ));
// }
if( f != null ) putDontOverwrite( childPrefs, OSCGUI.KEY_SWINGAPP, f.getAbsolutePath() );
}
// view
childPrefs = mainPrefs.node( NODE_VIEW );
try {
if( !childPrefs.nodeExists( NODE_SONAGRAM )) {
childPrefs2 = childPrefs.node( NODE_SONAGRAM );
new ConstQ().writePrefs( childPrefs2 );
}
}
catch( BackingStoreException e1 ) {
warnings.add( e1.toString() );