| PW wrote:
>select_pat(Verse2); # load it but don't do anything yet.
>shuffle_pfield (pfield(5, beats(4 to 9), *= 2));
>play();
I have not done too much OOP lately and not in Perl but I think it might
look something like if it were in C++ style:
Verse Verse1(pattern_from_file("some-score-file1.sco",[4 .. 10]));
Verse Verse2(pattern_from_file("some-score-file2.sco",[4 .. 10]));
Timer Time(0)
Verse1.Play(Time, 2);
Time.Set(0);
Verse2.Play(Time, 1);
Verse2.Shuffle(5, Beats(4, 9), 2); ???
Verse2.Play(Time, 1);
Something like that. I'm sure the C++ guru's can give better examples.
Some of the advantages lie in functions name clutter. You could have
Verse.Play() do one thing and Pattern.Play() and Song.Play(), do something
else. The three main ideas behind object oriented programming are
encapsulation, inheritance and polymorphism. Encapsulation as far as I
understand means that the variables and the functions are contained in the
class so that other classes can have the same local variables and local
functions without bugging neighboring classes.
I think Polymorphism means that a function can do different things depending
on the data you give it. A good example would be overloading + to do
something like:
int a=3, b=7;
c=a + b;
print(c);
10
string c="three", d="seven", e;
e=c + d;
print(e);
threeseven
Finally inheritance means that one class can inherit properties from a base
class.
I usually find that OOP makes things easier to use once you learn it.
Another advantage of OOP would be if you are writing large complex
applications with many different people. OOP generally makes for slower
bigger code. In this case the application is probably not time critical so
that won't matter. Some applications seem to be naturally object oriented
like windows systems with buttons, menus, scroll bars, etc. I can't tell if
this one is or not. If you have lots of different objects with lots of
similar operations performed on them like init, play, etc. then OO would be
useful.
One of the applications for a scoring language for me would be to call lots
of different fractals so it might be good to grab some equations from
fracint.
http://spanky.triumf.ca/www/fractint/fractint.html
These can probably be implemented as subroutines pretty easily though. I
started writing a Perl program which used fractals to generate score events
in a granular synthesis fashion.
Regards,
Hans Mikelson
|