Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
basicsynth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jean-Marie FAVREAU
basicsynth
Commits
ebb2dbd2
Commit
ebb2dbd2
authored
6 years ago
by
Jean-Marie FAVREAU
Browse files
Options
Downloads
Patches
Plain Diff
Génération d'une partition colorée
parent
8ad4b550
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
boomwhackers-8.json
+8
-8
8 additions, 8 deletions
boomwhackers-8.json
crescendo.py
+1
-0
1 addition, 0 deletions
crescendo.py
musique/exercice.py
+68
-7
68 additions, 7 deletions
musique/exercice.py
musique/gamme.py
+4
-2
4 additions, 2 deletions
musique/gamme.py
with
81 additions
and
17 deletions
boomwhackers-8.json
+
8
−
8
View file @
ebb2dbd2
{
"do1"
:
{
"couleur"
:
"#a73824"
,
"capsule"
:
"0"
},
"re1"
:
{
"couleur"
:
"#c56528"
,
"capsule"
:
"0"
},
"mi1"
:
{
"couleur"
:
"#f4e236"
,
"capsule"
:
"0"
},
"fa1"
:
{
"couleur"
:
"#f4e236"
,
"capsule"
:
"0"
},
"sol1"
:
{
"couleur"
:
"#27476d"
,
"capsule"
:
"0"
},
"la1"
:
{
"couleur"
:
"#413a88"
,
"capsule"
:
"0"
},
"si1"
:
{
"couleur"
:
"#682174"
,
"capsule"
:
"0"
},
"do2"
:
{
"couleur"
:
"#9c3922"
,
"capsule"
:
"0"
}
"do1"
:
{
"couleur"
:
[
167
,
56
,
36
]
,
"capsule"
:
"0"
},
"re1"
:
{
"couleur"
:
[
197
,
101
,
40
]
,
"capsule"
:
"0"
},
"mi1"
:
{
"couleur"
:
[
244
,
226
,
54
]
,
"capsule"
:
"0"
},
"fa1"
:
{
"couleur"
:
[
150
,
197
,
40
]
,
"capsule"
:
"0"
},
"sol1"
:
{
"couleur"
:
[
46
,
72
,
109
]
,
"capsule"
:
"0"
},
"la1"
:
{
"couleur"
:
[
62
,
58
,
135
]
,
"capsule"
:
"0"
},
"si1"
:
{
"couleur"
:
[
106
,
41
,
131
]
,
"capsule"
:
"0"
},
"do2"
:
{
"couleur"
:
[
151
,
55
,
30
]
,
"capsule"
:
"0"
}
}
This diff is collapsed.
Click to expand it.
crescendo.py
+
1
−
0
View file @
ebb2dbd2
...
...
@@ -38,6 +38,7 @@ crescendo = [ [ [gamme.do(3), gamme.noire],
if
args
.
exerciceSpectrogramme
:
g
=
GenerateurExercice
(
gamme
.
bpm
)
g
.
setBoomwhackers
(
boomwhackers
)
g
.
setLongueurPartitionColoree
(
4
)
g
.
genererExerciceSpectrogramme
(
crescendo
,
"
exercices/ex-spec-crescendo.tex
"
,
"
Crescendo
"
)
...
...
This diff is collapsed.
Click to expand it.
musique/exercice.py
+
68
−
7
View file @
ebb2dbd2
...
...
@@ -23,6 +23,13 @@ class GenerateurExercice(GammeTemperee):
self
.
margeFrequenceLegende
=
20
self
.
margeLegende
=
2.0
self
.
boomwhackers
=
[]
self
.
longueurPartitionColoree
=
4
# donne la largeur d'une ligne de partition colorée, exprimée
# en nombre de noires
def
setLongueurPartitionColoree
(
self
,
longueur
):
self
.
longueurPartitionColoree
=
longueur
def
setBoomwhackers
(
self
,
mw
):
import
json
...
...
@@ -245,8 +252,10 @@ class GenerateurExercice(GammeTemperee):
octaveCible
=
min
([
n
[
0
]
for
n
in
self
.
boomwhackers
if
n
[
1
]
==
minNote
[
1
]
]
+
[
10000
])
return
octaveCible
-
minNote
[
0
]
def
shiftNote
(
self
,
note
,
shiftOctave
):
return
(
note
[
0
]
+
shiftOctave
,
note
[
1
])
def
estJouable
(
self
,
note
,
shiftOctave
):
nN
=
(
note
[
0
]
+
shiftOctave
,
note
[
1
]
)
nN
=
self
.
shiftNote
(
note
,
shiftOctave
)
return
nN
in
self
.
boomwhackers
def
estDessinable
(
self
,
partitions
):
...
...
@@ -258,30 +267,82 @@ class GenerateurExercice(GammeTemperee):
minNote
=
min
(
notes
)
shiftOctave
=
self
.
getTranslationOctaveBoomwhackers
(
minNote
)
self
.
shiftOctave
=
self
.
getTranslationOctaveBoomwhackers
(
minNote
)
if
shiftOctave
>
100
:
if
self
.
shiftOctave
>
100
:
return
False
for
n
in
notes
:
if
not
self
.
estJouable
(
n
,
shiftOctave
):
if
not
self
.
estJouable
(
n
,
self
.
shiftOctave
):
return
False
return
True
def
couleurBoomwhackerToTikz
(
self
,
mw
):
return
"
\\
definecolor{tempcolor}{rgb}{
"
+
\
str
(
mw
[
"
couleur
"
][
0
]
/
255.
)
+
"
,
"
+
\
str
(
mw
[
"
couleur
"
][
1
]
/
255.
)
+
"
,
"
+
\
str
(
mw
[
"
couleur
"
][
2
]
/
255.
)
+
"
}
"
#return "{rgb, 255 :red, " + str(mw["couleur"][0]) \
#+ "; green, " + str(mw["couleur"][1]) \
#+ "; blue, " + str(mw["couleur"][2]) + "}"
def
pointColore
(
self
,
boomwhacker
,
x
,
y
,
r
):
result
=
self
.
couleurBoomwhackerToTikz
(
boomwhacker
)
result
+=
"
\\
fill[fill=tempcolor] (
"
+
\
str
(
x
)
+
"
,
"
+
str
(
y
)
+
"
) circle (
"
+
str
(
r
)
+
"
);
"
if
boomwhacker
[
"
capsule
"
]
==
"
1
"
:
result
+=
"
\\
fill [black] (
"
+
str
(
x
-
r
)
+
"
,
"
+
str
(
y
-
1.2
*
r
)
+
\
"
) rectangle (
"
+
str
(
x
+
r
)
+
"
,
"
+
str
(
y
-
1.9
*
r
)
+
"
);
"
return
result
def
partitionGraphique
(
self
,
partitions
):
result
=
""
frequences
=
self
.
notesDansPartition
(
partitions
)
x
=
0.
y
=
0.
stepx
=
2
stepy
=
2.5
finDeLigne
=
self
.
longueurPartitionColoree
*
stepx
nbl
=
1
if
self
.
estDessinable
(
partitions
):
p
=
partitions
[
0
]
result
+=
"
On peut la dessiner.
"
print
"
on peut la dessiner
"
# TODO
result
+=
"
\\
begin{tikzpicture}[]
"
for
note
in
p
:
print
note
if
x
==
0
:
result
+=
"
\\
node[draw] at (-
"
+
str
(
stepx
)
+
"
,
"
+
str
(
y
)
+
"
) {
"
+
str
(
nbl
)
+
"
};
"
if
isinstance
(
note
[
0
],
float
):
# on dessine le point
if
note
[
0
]
!=
0
:
n
=
self
.
shiftNote
(
self
.
getOctaveEtIDNote
(
note
[
0
]),
self
.
shiftOctave
)
mw
=
self
.
boomwhackers
[
n
]
result
+=
self
.
pointColore
(
mw
,
x
,
y
,
stepx
/
4.
)
# on calcule la translation pour le point suivant
x
+=
self
.
dureeEnNoires
(
note
[
1
])
*
stepx
if
x
>=
finDeLigne
:
x
=
0
y
-=
stepy
nbl
+=
1
result
+=
"
\\
end{tikzpicture}
"
else
:
result
+=
"
Cette partition n
'
est pas représentable sous forme de partition pour boomwhackers diatoniques.
"
print
result
return
result
# cette fonction écrit la fin de l'exercice spectrogramme
...
...
This diff is collapsed.
Click to expand it.
musique/gamme.py
+
4
−
2
View file @
ebb2dbd2
...
...
@@ -184,8 +184,10 @@ class GammeTemperee:
return
noms
[
duree
]
else
:
return
"
inconnue
"
def
dureeEnNoires
(
self
,
duree
):
return
duree
/
self
.
noire
# d'après wikipédia, «le triolet est une division exceptionnelle du temps, formée d'un
#groupe de trois figures égales dont la somme équivaut à deux figures identiques dans un
# temps normalement binaire. »
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment