-
Notifications
You must be signed in to change notification settings - Fork 0
/
ygg_midi_stat.R
74 lines (57 loc) · 1.6 KB
/
ygg_midi_stat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
# THE VOICE OF YGG
# Sonification of plants
# 17-10-2024
# Enjoy
# https://biosonification.altervista.org/sonification_quest_dominion_of_salt/
# https://www.soundcloud.com/thevoiceofygg
#
install.packages("tuneR")
library(tuneR)
#read the file
basicInfo<- tuneR::readMidi("C:/mypath/myfile.mid")
notes<-tuneR::getMidiNotes(basicInfo)
#This is where we are telling R to save our text file with the data
write.table(basicInfo,"Output location.txt",sep="\t",row.names=FALSE)
write.table(notes,"Output location2.txt",sep="\t",row.names=FALSE)
#
# Rapid calculus of Freq
#
install.packages('plyr')
library('plyr')
plyr::count(as.data.frame(notes), 'note')
plyr::count(as.data.frame(notes), 'notename')
#
# Detailed stats
#
install.packages("ggplot2")
library("ggplot2")
install.packages("forcats")
library(forcats)
levels(notes$notename)
#BARPLOT Notes/Count
ggplot(data=notes, aes(x= fct_infreq(notename),
fill=fct_infreq(notename))) +
geom_bar(width=0.5)+
coord_flip() +
labs(x="Notes")+
labs(y="Count")+
theme_minimal()+
theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1))+
theme(legend.position="none")+
theme(text = element_text(size = 8))
# ALL NOTES
x<-notes$time
y<-notes$note
z<-notes$velocity
label<-notes$notename
matrice<-matrix(nrow=length(x) , ncol=3)
matrice[,1]<-x
matrice[,2]<-y
matrice[,3]<-z
mastriceD<-as.data.frame(matrice)
colnames(mastriceD) <- c("time","note", "velocity")
ggplot(mastriceD, aes(x=time, y=label)) +
labs(y="Notes")+
labs(x="Time ms")+
geom_point(size=0.5, shape=21)