Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Malevolence Jones
Mar 29, 2006

JesusDoesVegas posted:


Delta (or anyone else) do you know of a more concise way to map these scales? Essentially the Auduino assigns a pot to play the instrument (I'm using a softpot for playability). That pot's analog input is mapped to frequencies dictated by the currently selected scale. Here's example of one map:

code:
// Key of C ........C D E F G A B 
uint16_t majorC [29] = {   
    274, 308, 346, 366, 411, 461, 518, 
    549, 616, 691, 732, 822, 923, 1036, 
    1097, 1232, 1383, 1465, 1644, 1845, 2071, 
    2195, 2463, 2765, 2930, 3288, 3691, 4143, 4389
       }; 

uint16_t mapMajorC(uint16_t input) { 
  uint8_t value = (1023-input) / (1024/29); 
  return (majorC[value]); 

I'm not 100% following along with what you want to accomplish, so I apologize if this solution isn't what you're looking to do, but I think you might be able to solve the problem like this:

1) Start with an array of pitch freqencies by semitone, which sounds like the midiTable referred to in the Google Group post you linked.

2) Create constants for each note you'll use as an entry point into the pitch array. Basically, your starting index value for accessing the array. E.g., C = 60

3) Create arrays for each type of scale you plan to use, with the values being the tone pattern. E.g., Major = 2,2,1,2,2,2,1 / Minor = 2,1,2,2,1,2,2

Putting it all together, if you wanted a C major scale... You'd start by looking up the array index for C (60) and the tone pattern of the major scale and then retrieve the relevant pitch frequencies starting with 60 then incrementing the index by 2, 2, 1, 2, etc.

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply