How to generate pitch strings

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to generate pitch strings

Atte Tenkanen
If I calculate a transition probability matrix, first order markov 12x12
or second order 144x144 from musical pitch classes (0-11), is it possible
to generate pitch class strings similar as those original strings using
those probability matrix with R? If, how?

Atte Tenkanen, Turku, Finland

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to generate pitch strings

Atte Tenkanen
> If I calculate a transition probability matrix, first order markov 12x12
> or second order 144x144 from musical pitch classes (0-11), is it possible
> to generate pitch class strings similar as those original strings using
> those probability matrix with R? If, how?
>
> Atte Tenkanen, Turku, Finland
>

I found this kind of solution:

j=1; a1=c();
Generated_Melody=c(1); #first note as a seed
a1=sample(1:12, size=1, prob=PT_matrix[j,]) # a seed for the loop following

for (i in 1:100){ # length of the generated melody will be 100
        Generated_Melody=c(Generated_Melody,a1)
        a1=sample(1:12, size=1, prob=PT_matrix[a1,])
}

# Generated_Melody=Generated_Melody-1;  # to picht classes
# Generated_Melody=Generated_Melody+59; # or to midi pitches


Atte Tenkanen

PS. Here is my page considering the course in which we use R for music
analysis...
http://musiikintutkimus.blogspot.com/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html