
set f [open $user/settings.tcl w]
set set_cmd {set-bpm set-style set-var set-delay}
set get_cmd {get-bpm get-style get-var get-delay}
set runs { {fm am gr os} {fm am gr} {am_depth fm_depth pitch_bend} {left right}}
set ncmds [llength $set_cmd]
for {set i 0} {$i < $ncmds} {incr i} {
  set run [lindex $runs $i]
  foreach j $run {
    set setj [lindex $set_cmd $i]
    set getj [lindex $get_cmd $i]
    set str "$setj $j [$getj $j]"
    puts $f $str
  }
}

foreach i {
	{"set-var location" "format {{%s}} [get-var location]"}
  {"tuning set" "tuning get"}
  {"load-scale microtonal_keyboard" "get-var microtonal_keyboard.scale"} 
	{"load-scale keyboard_keyboard" "get-var keyboard_keyboard.scale"}
	{"load-scale mondrian" "get-var mondrian.scale"}
	{"load-scale sounding_board" "get-var sounding_board.scale"}
	{"key microtonal_keyboard" "key microtonal_keyboard value"} 
	{"key keyboard_keyboard" "key keyboard_keyboard value"}
	{"key mondrian" "key mondrian value"}
	{"key sounding_board" "key sounding_board value"}
	{notation notation}
  {"set taptarget" "format {{%s}} [set taptarget]"}
  {"set-var scroll" "get-var scroll"}
  {"set-var zoom" "get-var zoom"}
  {"set-var pan" "get-var pan"}
  {"set-var fps" "get-var fps"}
	{"set-var ips" "get-var ips"}
  {"set-var num_sine_samples" "get-var num_sine_samples"}
  {"set-var show_pitch_volume" "get-var show_pitch_volume"}
  {"set-var drone_handle_size" "get-var drone_handle_size"}
  {"set-var trail_length" "get-var trail_length"}
  {"set-var voice_volume" "get-var voice_volume"}
  {"set-var note_volume" "get-var note_volume"}
  {"set-var attack_time" "get-var attack_time"}
  {"set-var sustain" "get-var sustain"}
  {"set-var decay_time" "get-var decay_time"}
  {"set-var delta_time" "get-var delta_time"}
  {"set-var instrument" "get-var instrument"}
	{"set-var midi_in" "get-var midi_in"}
  {"set-scope left" "format {{%s}} [get-scope left]"}
  {"set-scope right" "format {{%s}} [get-scope right]"}
  {"set-var show_nearby_notes" "get-var show_nearby_notes"}
  {"set-var show_parameters" "get-var show_parameters"}
  {"set-var delta_drone_master_volume" "get-var delta_drone_master_volume"}
  {set-kb-layout set-kb-layout}
  {"set-var fft" "get-var fft"}
  {"set-var current_plugin" "get-var current_plugin"}
  {"set-var fold_plugins" "get-var fold_plugins"}
	{"set-var mondrian.added_ball_type" "get-var mondrian.added_ball_type"}
  {"set-var mondrian.delta_speed" "get-var mondrian.delta_speed"}
	{"set-var mondrian.delta_rotate_velocity" "get-var mondrian.delta_rotate_velocity"}
  {"set-var mondrian.cursor" "get-var mondrian.cursor"}
  {"set-var mondrian.min_voices" "get-var mondrian.min_voices"}
	{"set-var mondrian.auto_adjust_voices" "get-var mondrian.auto_adjust_voices"}
  {"set-var mondrian.delta_attack_time" "get-var mondrian.delta_attack_time"}
  {"set-var mondrian.delta_decay_time" "get-var mondrian.delta_decay_time"}
	{"set-var mondrian.half_slit_size" "get-var mondrian.half_slit_size"}
	{"set-var mondrian.num_boxes" "get-var mondrian.num_boxes"}
	{"set-var mondrian.draw_boxes" "get-var mondrian.draw_boxes"}
	{"set-var mondrian.fill_boxes" "get-var mondrian.fill_boxes"}
	{"set-var mondrian.draw_notes" "get-var mondrian.draw_notes"}
	{"set-var mondrian.label_notes" "get-var mondrian.label_notes"}
  {"set-var mondrian.auto_split_rect" "get-var mondrian.auto_split_rect"}
  {"set-var mondrian.auto_split_time" "get-var mondrian.auto_split_time"}
  {"set-var mondrian.auto_split_orient" "get-var mondrian.auto_split_orient"}
  {"set-var mondrian.auto_split_at" "get-var mondrian.auto_split_at"}
  {"set-var mondrian.min_split_size" "get-var mondrian.min_split_size"}
  {"set-var mondrian.auto_delete_rect" "get-var mondrian.auto_delete_rect"}
  {"set-var mondrian.auto_delete_time" "get-var mondrian.auto_delete_time"}
  {"set-var mondrian.pick_box_split" "get-var mondrian.pick_box_split"}
	{"set-var mondrian.pick_box_delete" "get-var mondrian.pick_box_delete"}
	{"set-var mondrian.draw_ball_position" "get-var mondrian.draw_ball_position"}
	{"set-var mondrian.draw_ball_heading" "get-var mondrian.draw_ball_heading"}
	{"set-var mondrian.draw_ball_trails" "get-var mondrian.draw_ball_trails"}
	{"set-var mondrian.turn_sync" "get-var mondrian.turn_sync"}
	{"set-var mondrian.speed_sync" "get-var mondrian.speed_sync"}
	{"set-var sounding_board.master_volume" "get-var sounding_board.master_volume"}
	{"set-var sounding_board.separation" "get-var sounding_board.separation"}
	{"set-var sounding_board.spacing" "get-var sounding_board.spacing"}
	{"set-var sounding_board.pairs" "get-var sounding_board.pairs"}
	{"set-var sounding_board.starting_pitch" "get-var sounding_board.starting_pitch"}
	{"set-var sounding_board.close_octave" "get-var sounding_board.close_octave"}
  {"set-var sounding_board.justification" "get-var sounding_board.justification"}
  {"set-var sounding_board.keynote" "get-var sounding_board.keynote"}
  {"set-var sounding_board.resize_separation" "get-var sounding_board.resize_separation"}
	{"set-var sounding_board.fadet" "get-var sounding_board.fadet"}
	{"set-var mixing_time" "get-var mixing_time"}
  } {
  set setc [lindex $i 0]
  set getc [lindex $i 1]
  puts $f "$setc [eval $getc]"
}

foreach i {microtonal_keyboard_editors keyboard_keyboard_editors mondrian_editors sounding_board_editors} {
  puts $f "array set $i {[array get $i]}"
}

close $f
