Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Scale Listener
name
code content
( // Not refenrencing Ascending/descending scales // See Scale.sc var pentatonic_scales = [ \minorPentatonic, \majorPentatonic, \ritusen, \egyptian, \prometheus, \scriabin ]; var pentatonic_asian_scales = [ \kumoi, \hirajoshi, \iwato, \chinese, \indian, \pelog ]; var pentatonic_chinese_han_scales = [ \gong, \shang, \jiao, \zhi, \yu ]; var hexa_scales = [ \whole, \augmented, \augmented2 ]; var hexatonic_no_tritones_modes = [ \hexMajor7, \hexDorian, \hexPhrygian, \hexSus, \hexMajor6, \hexAeolian ]; var partch_otonalities = [ \partch_o1, \partch_o2, \partch_o3, \partch_o4, \partch_o5, \partch_o6 ]; var partch_utonalities = [ \partch_u1, \partch_u2, \partch_u3, \partch_u4, \partch_u5, \partch_u6 ]; var western_modes = [ \major, \dorian, \phrygian, \lydian, \mixolydian, \minor, \locrian ]; var western_harmo_melo_modes = [ \harmonicMinor, \harmonicMajor, \melodicMinor, \melodicMinorDesc, \melodicMajor ]; var hepta_other_modes = [ \hindu, \spanish, \bartok, \superLocrian, \romanianMinor, \hungarianMinor, \neapolitanMinor, \enigmatic ]; var raga_modes = [ \todi, \purvi, \marva, \bhairav, \ahirbhairav ]; var whole_tones_added = [ \leadingWhole, \lydianMinor, \neapolitanMajor, \locrianMajor ]; var eight_plus_scales = [ \diminished, \diminished2, \chromatic, \chromatic24 ]; var maqam_ajam = [ \ajam, \jiharkah, \shawqAfza ]; var maqam_sikah = [ \sikah, \sikahDesc, \huzam, \iraq, \bastanikar, \mustar ]; var maqam_bayati = [ \bayati, \karjighar, \husseini ]; var maqam_nahawand = [ \nahawand, \nahawandDesc, \farahfaza, \murassah, \ushaqMashri ]; var maqam_rast = [ \rast, \rastDesc, \suznak, \nairuz, \yakah, \yakahDesc, \mahur ]; var maqam_hijaz = [ \hijaz, \hijazDesc, \zanjaran, \hijazKar ]; var maqam_saba = [ \saba, \zamzam ]; var maqam_kurd = [ \kurd, \kijazKarKurd ]; var maqam_nawa_athar = [ \nawaAthar, \nikriz, \atharKurd ]; var all_groups = [ pentatonic_scales, pentatonic_asian_scales, pentatonic_chinese_han_scales, hexa_scales, hexatonic_no_tritones_modes, partch_otonalities, partch_utonalities, western_modes, western_harmo_melo_modes, hepta_other_modes, raga_modes, whole_tones_added, eight_plus_scales, maqam_ajam, maqam_sikah, maqam_bayati, maqam_nahawand, maqam_rast, maqam_hijaz, maqam_saba, maqam_kurd, maqam_nawa_athar ]; var group_names = [ "Pentatonic Scales", "Asian Pentatonic Scales", "Han Chinese Pentatonic Scales", "Six Notes Scales", "Hexatonic Modes With no Tritone", "Partch's Otonalities", "Partch's Utonalities", "Tonal modes", "Tonal harmonics and melodics modes", "Other heptatonic modes", "Raga modes", "Modes of whole tones with added note", "Eight, twelve and twenty-four notes modes", "Maqam Ajam", "Maqam Sikah", "Maqam Bayati", "Maqam Nahawand", "Maqam Rast", "Maqam Hijaz and HijazKar", "Maqam Saba", "Maqam Kurd", "Maqam Nawa Athar", "Maqam Bayati" ]; var view = Window.new( "Scale Listener", Rect.new( 0, 0, 1500, 700 ) ); var subview = UserView.new( view, Rect( 0, 0, view.bounds.width, view.bounds.height * 0.2 * all_groups.size ) ); var slider = Slider.new( view, Rect( view.bounds.width * 0.95, 0, view.bounds.width * 0.05, view.bounds.height ) ); var margin = 5; var play_scale = { | symbol | Pbind( \instrument, \simple_sine, \dur, 0.333, \freq, Pseq( ( 440 * Scale.at( symbol ).ratios ++ [ 880 ] ) ) ).play }; SynthDef(\simple_sine, { | out = 0, amp = 0.25, freq = 110 | var snd, env, envctl, envgen; env = Env.perc( 0.01, 0.666 ); envgen = EnvGen.kr( env, doneAction: Done.freeSelf ); snd = SinOsc.ar( [ freq, freq ], mul: 0.5 * amp * envgen ); Out.ar( out, snd ); }).add; all_groups.do( { | group, i | var group_title = StaticText.new( subview, Rect.new( 0, view.bounds.height * 0.2 * i, view.bounds.width, view.bounds.height * 0.1 ) ).string_( group_names[ i ] ).align_( \center ); var button_width = view.bounds.width * 0.95 - ( margin + 1 * group.size ) / group.size; group.do( { | symbol, j | var b = Button.new( subview, Rect.new( margin + ( ( button_width + margin ) * j ), view.bounds.height * 0.2 * i + ( view.bounds.height * 0.1 ), button_width, view.bounds.height * 0.1 ) ); b.states = [ [ Scale.at( symbol ).name, Color.white, Color.black ] ]; b.action = { play_scale.value( symbol ) }; } ); } ); slider.value = 1; slider.step = ( 1 / ( all_groups.size - 5 ) ); slider.thumbSize = ( view.bounds.height / ( all_groups.size - 5 ) ); slider.action = { var value = slider.value.linlin( 0, 1, subview.bounds.height - view.bounds.height, 0 ); subview.moveTo( 0, 0-value ); }; // Finally, bring the window to the front. view.front; CmdPeriod.doOnce({Window.closeAll}); // Kill GUI and server sounds on < Ctrl + ^ + . >, or on window closing . view.onClose = { s.freeAll; Window.closeAll; }; )
code description
The Scale Listener is a simple GUI that previews every scale provided in SC, except Ascending/Descending ones. Can also serve as a template for a graphical scale selector, or for didactic purposes.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change