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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jean-Marie FAVREAU
basicsynth
Commits
1698770a
Commit
1698770a
authored
Apr 9, 2019
by
Jean-Marie FAVREAU
Browse files
Options
Downloads
Patches
Plain Diff
Pas mal d'ajustements, notamment de la correctino
parent
52cc655c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
musique/exercice.py
+120
-71
120 additions, 71 deletions
musique/exercice.py
with
120 additions
and
71 deletions
musique/exercice.py
+
120
−
71
View file @
1698770a
...
...
@@ -179,8 +179,10 @@ class GenerateurExercice(GammeTemperee):
# retourne un tableau des durées des notes possibles dans la partition
def
tableauDurees
(
self
,
partitions
):
def
tableauDurees
(
self
,
partitions
,
beamer
=
False
):
result
=
"
\n
"
if
not
beamer
:
if
not
self
.
tableauSimplifie
:
result
+=
"
Cette partition est proposée à une fréquence de
"
+
str
(
self
.
bpm
)
+
"
noires par minute, ce qui donne les durées suivantes.
"
else
:
...
...
@@ -188,6 +190,11 @@ class GenerateurExercice(GammeTemperee):
ds
=
self
.
durees
(
partitions
)
if
beamer
:
result
+=
'
\\
resizebox{1
\\
textwidth}{!}{%
\n
'
else
:
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
result
+=
"
\\
begin{tabular}{|l
"
+
""
.
join
([
"
|c
"
for
d
in
ds
])
+
"
|}
\n
"
result
+=
"
\\
hline
\n
"
...
...
@@ -201,7 +208,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\\\
\n
"
result
+=
"
\\
hline
\n
"
if
not
self
.
tableauSimplifie
:
if
not
self
.
tableauSimplifie
and
not
beamer
:
result
+=
"
\\
textbf{Longueur} (cm)
"
for
duree
in
ds
:
result
+=
"
&
"
+
'
{0:.2f}
'
.
format
(
self
.
dureeEnCm
(
duree
)).
replace
(
"
.
"
,
"
,
"
)
...
...
@@ -222,9 +229,13 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
end{tabular}
\n
"
if
beamer
:
result
+=
"
}
\n
"
else
:
result
+=
"
\\
caption{Table des durées}
\n
"
result
+=
"
\\
end{table}
\n
"
return
result
# retourne un tableau LaTeX décrivant la partition sous forme brute (fréquence
...
...
@@ -233,6 +244,8 @@ class GenerateurExercice(GammeTemperee):
# on ne va utiliser que la première partition
partition
=
partitions
[
0
]
self
.
setShiftOctave
(
partitions
)
result
=
"
\\
renewcommand{
\\
arraystretch}{1.3}
"
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
if
len
(
partition
)
>
30
:
...
...
@@ -248,7 +261,19 @@ class GenerateurExercice(GammeTemperee):
if
isinstance
(
note
[
0
],
float
):
if
note
[
0
]
>
0
:
result
+=
self
.
frequenceToLaTeX
(
note
[
0
],
self
.
minOctave
,
self
.
maxOctave
)
+
"
&
"
+
self
.
nomDuree
(
note
[
1
])
+
"
&
\\\\\n
"
self
.
minOctave
,
self
.
maxOctave
)
+
"
&
"
+
self
.
nomDuree
(
note
[
1
])
+
"
&
"
# ajout note graphique
result
+=
"
\\
begin{tikzpicture}[]
"
nid
=
self
.
shiftNote
(
self
.
getOctaveEtIDNote
(
note
[
0
]),
self
.
shiftOctave
)
mw
=
self
.
boomwhackers
[
nid
]
if
len
(
partition
)
>
30
:
result
+=
self
.
pointColore
(
mw
,
0
,
0
,
0.15
)
else
:
result
+=
self
.
pointColore
(
mw
,
0
,
0
,
0.2
)
result
+=
"
\\
end{tikzpicture}
"
result
+=
"
\\\\\n
"
result
+=
"
\\
hline
\n
"
else
:
result
+=
"
&
"
+
self
.
nomDuree
(
note
[
1
])
+
"
&
\\\\\n
"
...
...
@@ -272,14 +297,19 @@ class GenerateurExercice(GammeTemperee):
return
result
def
tableauFrequences
(
self
,
partitions
):
def
tableauFrequences
(
self
,
partitions
,
beamer
=
False
):
result
=
""
notes
=
self
.
getOctaveEtIDNoteDansIntervalle
(
self
.
minFrequence
(
partitions
),
self
.
maxFrequence
(
partitions
))
if
not
beamer
:
result
+=
"
Fréquences de chacune des notes utilisées sur la partition (arrondies à l
'
entier le plus proche):
"
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
if
beamer
:
result
+=
"
{
\\
footnotesize
\n
\\
begin{center}
\n
"
else
:
result
+=
"
\\
begin{table}[H]
\n\\
centering
\n
"
result
+=
"
\\
begin{tabular}{|c|c|}
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
textbf{Fréquence} (Hz) &
\\
textbf{Note}
\\\\
\n
"
...
...
@@ -291,11 +321,15 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
hline
\n
"
result
+=
"
\\
end{tabular}
\n
"
if
not
beamer
:
result
+=
"
\\
caption{Table des fréquences de la gamme tempérée}
\n
"
result
+=
"
\\
end{table}
\n
"
if
self
.
contientSilences
(
partitions
):
if
self
.
contientSilences
(
partitions
)
and
not
beamer
:
result
+=
"
Attention, la partition peut également contenir des silences, dont on peut mesurer la longueur, comme les notes
"
if
beamer
:
result
+=
"
\\
end{center}}
\n
"
return
result
# retourne la translation d'octave nécessaire pour jouer avec
...
...
@@ -311,11 +345,7 @@ class GenerateurExercice(GammeTemperee):
nN
=
self
.
shiftNote
(
note
,
shiftOctave
)
return
nN
in
self
.
boomwhackers
def
estDessinable
(
self
,
partitions
):
if
len
(
partitions
)
!=
1
:
print
"
La partition contient plusieurs mains.
"
return
False
def
setShiftOctave
(
self
,
partitions
):
notes
=
[
self
.
getOctaveEtIDNote
(
p
)
for
p
in
self
.
notesDansPartition
(
partitions
)
]
minNote
=
min
(
notes
)
...
...
@@ -335,9 +365,17 @@ class GenerateurExercice(GammeTemperee):
if
not
self
.
estJouable
(
n
,
self
.
shiftOctave
):
self
.
shiftOctave
-=
1
break
return
True
def
estDessinable
(
self
,
partitions
):
if
len
(
partitions
)
!=
1
:
print
"
La partition contient plusieurs mains.
"
return
False
return
self
.
setShiftOctave
(
partitions
)
return
True
def
couleurBoomwhackerToTikz
(
self
,
mw
):
return
"
\\
definecolor{tempcolor}{rgb}{
"
+
\
...
...
@@ -372,10 +410,12 @@ class GenerateurExercice(GammeTemperee):
notesTotales
=
sorted
(
list
(
set
(
frequences
)))
result
+=
"
\\
begin{table}[H]
\
n
\
centering
\n
"
result
+=
"
\\
begin{table}[H]\centering
\n
"
if
len
(
notesTotales
)
>
12
:
n
=
[
notesTotales
[:
12
],
notesTotales
[
12
:]
]
else
:
n
=
[
notesTotales
]
for
notes
in
n
:
result
+=
'
\\
resizebox{1
\\
textwidth}{!}{%
\n
'
...
...
@@ -415,7 +455,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
hline
\n
"
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
}
\n
"
result
+=
"
\\
newline
\n
\\
\n
"
#
result += " \\newline \n"
result
+=
"
\\
caption{Représentation colorée des notes}
\n
"
result
+=
"
\\
end{table}
\n
"
...
...
@@ -428,7 +468,7 @@ class GenerateurExercice(GammeTemperee):
if
beamer
:
result
+=
"
\\
frame{
"
result
+=
"
\\
frametitle{Représentation graphique}
"
result
+=
"
\\
frametitle{Représentation graphique}
\n
"
frequences
=
self
.
notesDansPartition
(
partitions
)
...
...
@@ -458,9 +498,9 @@ class GenerateurExercice(GammeTemperee):
if
beamer
:
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
result
+=
"
}
"
result
+=
"
\\
frame{
"
result
+=
"
\\
frametitle{Représentation graphique}
"
result
+=
"
}
\n
"
result
+=
"
\\
frame{
\n
"
result
+=
"
\\
frametitle{Représentation graphique}
\n
"
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
...
...
@@ -497,7 +537,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
Cette partition n
'
est pas représentable sous forme de partition pour boomwhackers diatoniques.
"
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
def
partitionMusicale
(
self
,
partitions
,
beamer
=
False
):
...
...
@@ -539,7 +579,7 @@ class GenerateurExercice(GammeTemperee):
if
note
[
0
]
!=
0
:
result
+=
self
.
dureeToMusicTex
(
note
[
1
])
+
"
{
"
result
+=
self
.
frequenceToMusicTeX
(
note
[
0
],
midOctave
)
result
+=
"
}
"
result
+=
"
}
\n
"
longueurCourante
+=
note
[
1
]
else
:
# TODO
...
...
@@ -561,7 +601,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
Le générateur d
'
exercice ne prend pas en charge cette partition.
"
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
...
...
@@ -783,7 +823,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
end{tikzpicture}
"
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
...
...
@@ -853,15 +893,24 @@ class GenerateurExercice(GammeTemperee):
l_fichier
.
write
(
self
.
spectrogramme
(
partitions
,
True
))
l_fichier
.
write
(
"
\\
frame{
\n
"
)
l_fichier
.
write
(
"
\\
frametitle{Durées et notes}
\n
"
)
# on écrit le tableau de durées
l_fichier
.
write
(
self
.
tableauDurees
(
partitions
,
True
))
# on écrit le tableau des fréquences
l_fichier
.
write
(
self
.
tableauFrequences
(
partitions
,
True
))
l_fichier
.
write
(
"
}
\n
"
)
l_fichier
.
write
(
self
.
partitionGraphique
(
partitions
,
True
))
l_fichier
.
write
(
self
.
partitionMusicale
(
partitions
,
True
))
if
nomSolution
!=
""
:
result
=
"
\\
frame{
"
result
=
"
\\
frame{
\n
"
result
+=
"
\\
frametitle{Solution}
\n
"
result
+=
"
\\
begin{center}\Large Cette mélodie s
'
appelle
"
+
nomSolution
+
"
\\
end{center}
"
result
+=
"
}
"
result
+=
"
}
\n
"
l_fichier
.
write
(
result
)
...
...
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