| e8555c89 Andy McCall |
1 |
namespace eval psg_profile { |
| 2 |
|
| 3 |
set_help_text psg_profile \ |
| 4 |
{Select a PSG sound profile. |
| 5 |
|
| 6 |
Usage: |
| 7 |
psg_profile Shows the current profile |
| 8 |
psg_profile -list Shows the possible profiles |
| 9 |
psg_profile <profile> Select a new profile |
| 10 |
} |
| 11 |
|
| 12 |
variable psg_settings {::PSG_vibrato_percent ::PSG_vibrato_frequency |
| 13 |
::PSG_detune_percent ::PSG_detune_frequency} |
| 14 |
variable psg_profiles [dict create \ |
| 15 |
normal { 0.0 - 0.0 - } \ |
| 16 |
vibrato { 1.0 5.0 0.0 - } \ |
| 17 |
detune { 0.0 - 0.5 5.0 } \ |
| 18 |
detune_vibrato { 1.0 5.0 0.5 5.0 }] |
| 19 |
|
| 20 |
set_tabcompletion_proc psg_profile [namespace code tab_psg_profile] |
| 21 |
proc tab_psg_profile {args} { |
| 22 |
variable psg_profiles |
| 23 |
set result [dict keys $psg_profiles] |
| 24 |
lappend result "-list" |
| 25 |
} |
| 26 |
|
| 27 |
proc equal_psg_profile {values} { |
| 28 |
variable psg_settings |
| 29 |
foreach setting $psg_settings value $values { |
| 30 |
if {$value ne "-"} { |
| 31 |
if {[set $setting] != $value} { |
| 32 |
return false |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
return true |
| 37 |
} |
| 38 |
|
| 39 |
proc get_psg_profile {} { |
| 40 |
variable psg_settings |
| 41 |
set result [list] |
| 42 |
foreach setting $psg_settings { |
| 43 |
lappend result [set $setting] |
| 44 |
} |
| 45 |
return $result |
| 46 |
} |
| 47 |
|
| 48 |
proc set_psg_profile {values} { |
| 49 |
variable psg_settings |
| 50 |
foreach setting $psg_settings value $values { |
| 51 |
if {$value ne "-"} { |
| 52 |
set $setting $value |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
proc psg_profile {{profile ""}} { |
| 58 |
variable psg_profiles |
| 59 |
if {$profile eq ""} { |
| 60 |
dict for {name value} $psg_profiles { |
| 61 |
if {[equal_psg_profile $value]} { |
| 62 |
return $name |
| 63 |
} |
| 64 |
} |
| 65 |
return "Custom profile: [get_psg_profile]" |
| 66 |
} elseif {$profile eq "-list"} { |
| 67 |
return [dict keys $psg_profiles] |
| 68 |
} else { |
| 69 |
if {![dict exists $psg_profiles $profile]} { |
| 70 |
error "No such profile: $profile" |
| 71 |
} |
| 72 |
set_psg_profile [dict get $psg_profiles $profile] |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
namespace export psg_profile |
| 77 |
|
| 78 |
} ; |
| 79 |
|
| 80 |
namespace import psg_profile::* |