Re: Help

new topic     » goto parent     » topic index » view thread      » older message » newer message

Albert Brauneis wrote:
>
> That didn't work, tempnote is still {a,-} and not {a-}
>
> Albert
there is no data structure or technique that will give you
that result.  even "a-" is *still* {a,-}, no matter the
language of programming, a string is a list of individual
characters that are incongrous.
the program is actually doing what you 1>want and what you
2>need it to do...
it's all about how you access data, how you order data,
how you think about data, and how you process data.
in euphoria, these 4 things are truly childs play.

let's suppose that we have a list of notes
that are in order that represent a scale.
now, i'm not a sheet music reader, and i don't
remember the scale.
let's just say that its:
constant scale
scale = "c#c-c+d#d-d+e#e-e+f#f-f+g#g-g+a#a-a+b#b-b+"
# is flat and + is sharp...not that it matters here
now lets suppose that you have a song, composed
of notes that need to be within this scale...
sequence song
song = "f#c-a#g+e+d#b-b-c-a+"
at this point i'm assuming that you have many sets of
scales and somehow you're attempting to determine an
octave... once again, that is no matter...
to determine if each note in song is within
the allowable notes in scale, do the following:

function IsInScale(sequence note)
--returns 0 if the note is not in the constant scale
--returns the place within scale if it is
   for i = 1 to length(scale) by 2 do
        if compare(note,scale[i..i+1) = 0
          then return i
        end if
   end for
   return 0
end function
the above function is the methodology of how
the find() and match() functions operate,
and it's important that you see this.  Why?
how can you expect to understand that which
you cannot see? if you don't know the underlying
algorithm behind a function, you cannot ask that
function to do things for you...
so now we push forwards, safe in our new knowledge,
and we can then see how simple it will be to
go through an entire song, replete with this
armada of fresh understanding...

to check an entire song, we need only do the
following:
   for i = 1 to length(song) by 2
      if IsInScale(song[i..i+1]) then
        --we can do what ever we like here,
        --including actually saving the value returned
        --by the above function, if need be
      else puts(1,"invalid note detected in song")
      end if
    end for

voila, data has succumbed to our whim...

hope this helps--Hawke'

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu