![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: problem combining two scripts into one | |
Phi Curtis Member |
![]() ![]() ![]()
I have two bits of code that, when I combine them together into a single script, seem to interfere with each other. I'm trying to define scale formulas in a script that I can then reference in pitch fields within my sound. The scales are defined like so: You can see that this defines the scale as a series of intervals above a tonic note. I would then use, in a pitch field, a formula like: Here's my question: I would like to have the script also automatically generate the modes of the scale that I give. So that, in this example, the modes of the major scale could be created by the script, and then automatically be given names that could also be accessed as green variables in pitch fields. I basically just want to save myself the trouble of manually writing out the intervals of all the modes of the original scale I defined (I intend to create a large compendium of scales to have easy access to in my sounds). I have code that generates the modes like so: | majorScale mode numberOfMode subtractForNewStartingNote intervalOfEndingNote| 1 to: (mode size) do: mode := mode asOrderedCollection. 1 to: numberOfMode - 1 mode addLast: intervalOfEndingNote. "add ending note back in again." mode := mode "define green variable" This works well. However, you can see by the sounds in the attached sound file that I am able to get this working when I use two bits of code separately, but when I combine them into a single script, I inadvertantly redefine the major scale variable. Play the attached sounds and you'll see what I mean. I'm not sure why the original major scale array is being altered, since the changes I am making are all to the mode array. [Actually, I do have a version that works, marked "DOES WORK" in the attached file. What I have done is just paste in the same array when defining "mode," instead of saying "mode := major." But now I'm curious why this one works and the other doesn't, since I don't think manipulations that I do to the "mode" array should effect the "major" array. And anyway, my question still stands because I would like help figuring out how I can make this code generate all possible modes, and then automatically assign them names like "majorMode1," "majorMode2," etc.] I also would like to have script generate/construct a new green variable name. ie major conflated with "Mode1" = majorMode1. This would be set up to automatically generate modes. My ultimate goal is to have a piece of code within a same script that: 1. defines a scale (in this case, a major scale) 2. automatically generates the various modes of that scale (i.e it goes through and defines as many modes as are possible until it comes to the octave repeat of the scale. Or just generates every possible mode of the original array). 3. names the modes automatically (ike "majorMode1," "majorMode2," etc.) so that they can be referenced in the sound as green variables. Thanks for your help. Phil [This message has been edited by Phi Curtis (edited 05 December 2008).] IP: Logged | |
Luddy Member |
![]() ![]() ![]() Hi, This statement: You could fix this by copying majorScale before assigning it to mode. I think a more straightforward fix however is to use a 'collect' form to create the mode. You could use something like Concerning the overall structure, you might consider making a mode generator function, something like ModeGenerator := [ :Scale :ModeOffset | ... ]. You could then call it repeatedly to generate the various modes of a scale. This way you the generator would not be sensitive to the names of the original scale and the modes. hth, -Luddy [This message has been edited by Luddy (edited 05 December 2008).] IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]() Thanks Luddy. I had a feeling that's what was happening (the assignment operation was making the two arrays into effectively the same array). There must be a way to do what I'm trying here without having the two arrays be exactly the same array...I need to study Smalltalk a bit more. This variation of your suggestion does what I want, without having to paste the same array twice: major := #(0 2 4 5 7 9 11 12 14 16 17 19 21 23 24 26 28 29 31 33 35 36 38 40 41 43 45 47 48 50 52 53 55 57 59 60 62 64 65 67 69 71 72). Then, for the rest, I guess I'll try putting the whole mode-creating code into an iterative statement that also constructs unique names for each one... IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]() quote: I think I understand what you mean. I'll play with it. I need to read up on Smalltalk... IP: Logged | |
SSC Administrator |
![]() ![]() ![]()
code: !Mode is a number from 0 to 6 that shifts where in the interval pattern you start the scale. Once you have the interval above the tonic, you can add it to !Tonic. The last step is to subtract the pitch offset (!Mode of: ?major). This would give the interval pattern of a major scale starting on the (!Mode + 1) degree of the scale but it would start on whatever you supply as the !Tonic. I've attached a funny little example that just plays the scales for testing. (If you add 7 extra intervals at the top of your original array, you can avoid the complication of taking the newly computed index modulo the size of the array). IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]()
That code is useful. See my attached variation, which has one fader to choose the scale, and another fader to choose the mode derived from that scale (although technically I don't think the terms dorian, phrygian, etc. apply when they are derived from the melodic and harmonic minor scales...). The one problem I have with this approach is figuring out what to do when the !ScaleChoice fader is choosing between scales that have other numbers of notes per octave. Phil IP: Logged | |
SSC Administrator |
![]() ![]() ![]() quote: You probably know this already but in case anyone reading this has not played around with this feature yet: To change the names of the tic marks on a fader: Unlock the VCS Double-click the Fader Under Options choose Set tick marks and labels Then click Edit to change the label names
quote: Well, you would lose the label names this way but you could make !Mode a (0,1) variable and then, when you select a scale, you could also use that as a way to select the appropriate multiplier on !Mode. The multiplier would be equal to the number of steps per octave - 1. IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]() quote: That's true. But I like not just the labels, but also the fact that there are stops/notches in the fader, rather than having a continuous fader. It makes the interface somehow more hardware-like. Thanks again for the help. [This message has been edited by Phi Curtis (edited 08 December 2008).] IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.