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
1698770a
"content/slides/1337/js.html" did not exist on "4310058661a2fbda105eefc679e4a9ebef487deb"
Commit
1698770a
authored
6 years ago
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
Hide 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,16 +179,23 @@ class GenerateurExercice(GammeTemperee):
...
@@ -179,16 +179,23 @@ class GenerateurExercice(GammeTemperee):
# retourne un tableau des durées des notes possibles dans la partition
# retourne un tableau des durées des notes possibles dans la partition
def
tableauDurees
(
self
,
partitions
):
def
tableauDurees
(
self
,
partitions
,
beamer
=
False
):
result
=
"
\n
"
result
=
"
\n
"
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.
"
if
not
beamer
:
else
:
if
not
self
.
tableauSimplifie
:
result
+=
"
Les durées traits sur le graphique peuvent être traduites en durée musicale
"
result
+=
"
Cette partition est proposée à une fréquence de
"
+
str
(
self
.
bpm
)
+
"
noires par minute, ce qui donne les durées suivantes.
"
else
:
result
+=
"
Les durées traits sur le graphique peuvent être traduites en durée musicale
"
ds
=
self
.
durees
(
partitions
)
ds
=
self
.
durees
(
partitions
)
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
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
+=
"
\\
begin{tabular}{|l
"
+
""
.
join
([
"
|c
"
for
d
in
ds
])
+
"
|}
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
hline
\n
"
...
@@ -201,7 +208,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -201,7 +208,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\\\
\n
"
result
+=
"
\\\\
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
hline
\n
"
if
not
self
.
tableauSimplifie
:
if
not
self
.
tableauSimplifie
and
not
beamer
:
result
+=
"
\\
textbf{Longueur} (cm)
"
result
+=
"
\\
textbf{Longueur} (cm)
"
for
duree
in
ds
:
for
duree
in
ds
:
result
+=
"
&
"
+
'
{0:.2f}
'
.
format
(
self
.
dureeEnCm
(
duree
)).
replace
(
"
.
"
,
"
,
"
)
result
+=
"
&
"
+
'
{0:.2f}
'
.
format
(
self
.
dureeEnCm
(
duree
)).
replace
(
"
.
"
,
"
,
"
)
...
@@ -222,8 +229,12 @@ class GenerateurExercice(GammeTemperee):
...
@@ -222,8 +229,12 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
\\
caption{Table des durées}
\n
"
if
beamer
:
result
+=
"
\\
end{table}
\n
"
result
+=
"
}
\n
"
else
:
result
+=
"
\\
caption{Table des durées}
\n
"
result
+=
"
\\
end{table}
\n
"
return
result
return
result
...
@@ -233,6 +244,8 @@ class GenerateurExercice(GammeTemperee):
...
@@ -233,6 +244,8 @@ class GenerateurExercice(GammeTemperee):
# on ne va utiliser que la première partition
# on ne va utiliser que la première partition
partition
=
partitions
[
0
]
partition
=
partitions
[
0
]
self
.
setShiftOctave
(
partitions
)
result
=
"
\\
renewcommand{
\\
arraystretch}{1.3}
"
result
=
"
\\
renewcommand{
\\
arraystretch}{1.3}
"
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
if
len
(
partition
)
>
30
:
if
len
(
partition
)
>
30
:
...
@@ -248,7 +261,19 @@ class GenerateurExercice(GammeTemperee):
...
@@ -248,7 +261,19 @@ class GenerateurExercice(GammeTemperee):
if
isinstance
(
note
[
0
],
float
):
if
isinstance
(
note
[
0
],
float
):
if
note
[
0
]
>
0
:
if
note
[
0
]
>
0
:
result
+=
self
.
frequenceToLaTeX
(
note
[
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
"
result
+=
"
\\
hline
\n
"
else
:
else
:
result
+=
"
&
"
+
self
.
nomDuree
(
note
[
1
])
+
"
&
\\\\\n
"
result
+=
"
&
"
+
self
.
nomDuree
(
note
[
1
])
+
"
&
\\\\\n
"
...
@@ -272,14 +297,19 @@ class GenerateurExercice(GammeTemperee):
...
@@ -272,14 +297,19 @@ class GenerateurExercice(GammeTemperee):
return
result
return
result
def
tableauFrequences
(
self
,
partitions
):
def
tableauFrequences
(
self
,
partitions
,
beamer
=
False
):
result
=
""
result
=
""
notes
=
self
.
getOctaveEtIDNoteDansIntervalle
(
self
.
minFrequence
(
partitions
),
self
.
maxFrequence
(
partitions
))
notes
=
self
.
getOctaveEtIDNoteDansIntervalle
(
self
.
minFrequence
(
partitions
),
self
.
maxFrequence
(
partitions
))
result
+=
"
Fréquences de chacune des notes utilisées sur la partition (arrondies à l
'
entier le plus proche):
"
if
not
beamer
:
result
+=
"
\\
begin{table}[H]
\n
\centering
\n
"
result
+=
"
Fréquences de chacune des notes utilisées sur la partition (arrondies à l
'
entier le plus proche):
"
if
beamer
:
result
+=
"
{
\\
footnotesize
\n
\\
begin{center}
\n
"
else
:
result
+=
"
\\
begin{table}[H]
\n\\
centering
\n
"
result
+=
"
\\
begin{tabular}{|c|c|}
\n
"
result
+=
"
\\
begin{tabular}{|c|c|}
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
textbf{Fréquence} (Hz) &
\\
textbf{Note}
\\\\
\n
"
result
+=
"
\\
textbf{Fréquence} (Hz) &
\\
textbf{Note}
\\\\
\n
"
...
@@ -291,11 +321,15 @@ class GenerateurExercice(GammeTemperee):
...
@@ -291,11 +321,15 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
hline
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
\\
caption{Table des fréquences de la gamme tempérée}
\n
"
if
not
beamer
:
result
+=
"
\\
end{table}
\n
"
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
"
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
return
result
# retourne la translation d'octave nécessaire pour jouer avec
# retourne la translation d'octave nécessaire pour jouer avec
...
@@ -311,15 +345,11 @@ class GenerateurExercice(GammeTemperee):
...
@@ -311,15 +345,11 @@ class GenerateurExercice(GammeTemperee):
nN
=
self
.
shiftNote
(
note
,
shiftOctave
)
nN
=
self
.
shiftNote
(
note
,
shiftOctave
)
return
nN
in
self
.
boomwhackers
return
nN
in
self
.
boomwhackers
def
estDessinable
(
self
,
partitions
):
def
setShiftOctave
(
self
,
partitions
):
if
len
(
partitions
)
!=
1
:
print
"
La partition contient plusieurs mains.
"
return
False
notes
=
[
self
.
getOctaveEtIDNote
(
p
)
for
p
in
self
.
notesDansPartition
(
partitions
)
]
notes
=
[
self
.
getOctaveEtIDNote
(
p
)
for
p
in
self
.
notesDansPartition
(
partitions
)
]
minNote
=
min
(
notes
)
minNote
=
min
(
notes
)
self
.
shiftOctave
=
self
.
getTranslationOctaveBoomwhackers
(
minNote
)
self
.
shiftOctave
=
self
.
getTranslationOctaveBoomwhackers
(
minNote
)
if
self
.
shiftOctave
>
100
:
if
self
.
shiftOctave
>
100
:
...
@@ -335,10 +365,18 @@ class GenerateurExercice(GammeTemperee):
...
@@ -335,10 +365,18 @@ class GenerateurExercice(GammeTemperee):
if
not
self
.
estJouable
(
n
,
self
.
shiftOctave
):
if
not
self
.
estJouable
(
n
,
self
.
shiftOctave
):
self
.
shiftOctave
-=
1
self
.
shiftOctave
-=
1
break
break
return
True
return
True
def
estDessinable
(
self
,
partitions
):
if
len
(
partitions
)
!=
1
:
print
"
La partition contient plusieurs mains.
"
return
False
return
self
.
setShiftOctave
(
partitions
)
def
couleurBoomwhackerToTikz
(
self
,
mw
):
def
couleurBoomwhackerToTikz
(
self
,
mw
):
return
"
\\
definecolor{tempcolor}{rgb}{
"
+
\
return
"
\\
definecolor{tempcolor}{rgb}{
"
+
\
str
(
mw
[
"
couleur
"
][
0
]
/
255.
)
+
"
,
"
+
\
str
(
mw
[
"
couleur
"
][
0
]
/
255.
)
+
"
,
"
+
\
...
@@ -372,50 +410,52 @@ class GenerateurExercice(GammeTemperee):
...
@@ -372,50 +410,52 @@ class GenerateurExercice(GammeTemperee):
notesTotales
=
sorted
(
list
(
set
(
frequences
)))
notesTotales
=
sorted
(
list
(
set
(
frequences
)))
result
+=
"
\\
begin{table}[H]
\
n
\
centering
\n
"
result
+=
"
\\
begin{table}[H]\centering
\n
"
if
len
(
notesTotales
)
>
12
:
if
len
(
notesTotales
)
>
12
:
n
=
[
notesTotales
[:
12
],
notesTotales
[
12
:]
]
n
=
[
notesTotales
[:
12
],
notesTotales
[
12
:]
]
else
:
n
=
[
notesTotales
]
for
notes
in
n
:
for
notes
in
n
:
result
+=
'
\\
resizebox{1
\\
textwidth}{!}{%
\n
'
result
+=
'
\\
resizebox{1
\\
textwidth}{!}{%
\n
'
if
not
beamer
:
if
not
beamer
:
result
+=
"
\\
begin{tabular}{|r|
"
+
""
.
join
([
"
c|
"
]
*
len
(
notes
))
+
"
}
\n
"
result
+=
"
\\
begin{tabular}{|r|
"
+
""
.
join
([
"
c|
"
]
*
len
(
notes
))
+
"
}
\n
"
else
:
else
:
result
+=
"
\\
begin{tabular}{r|
"
+
""
.
join
([
"
c
"
]
*
len
(
notes
))
+
"
}
\n
"
result
+=
"
\\
begin{tabular}{r|
"
+
""
.
join
([
"
c
"
]
*
len
(
notes
))
+
"
}
\n
"
if
not
beamer
:
if
not
beamer
:
result
+=
"
\\
hline
\n
"
result
+=
"
\\
hline
\n
"
result
+=
"
Notes
"
result
+=
"
Notes
"
for
n
in
notes
:
for
n
in
notes
:
result
+=
"
&
"
result
+=
"
&
"
if
beamer
:
if
beamer
:
result
+=
"
\\
hspace*{.2cm}
"
result
+=
"
\\
hspace*{.2cm}
"
result
+=
self
.
frequenceToLaTeX
(
n
,
self
.
minOctave
,
self
.
maxOctave
)
result
+=
self
.
frequenceToLaTeX
(
n
,
self
.
minOctave
,
self
.
maxOctave
)
if
beamer
:
if
beamer
:
result
+=
"
\\
hspace*{.2cm}
"
result
+=
"
\\
hspace*{.2cm}
"
result
+=
"
\\\\
\n
"
result
+=
"
\\\\
\n
"
result
+=
"
Forme
"
result
+=
"
Forme
"
for
n
in
notes
:
result
+=
"
&
"
result
+=
"
\\
begin{tikzpicture}[]
"
nid
=
self
.
shiftNote
(
self
.
getOctaveEtIDNote
(
n
),
self
.
shiftOctave
)
mw
=
self
.
boomwhackers
[
nid
]
result
+=
self
.
pointColore
(
mw
,
0
,
0
,
radius
)
result
+=
"
\\
end{tikzpicture}
"
result
+=
"
\\\\
\n
"
if
not
beamer
:
result
+=
"
Prénom
"
for
n
in
notes
:
for
n
in
notes
:
result
+=
"
&
"
result
+=
"
&
"
result
+=
"
\\
begin{tikzpicture}[]
"
result
+=
"
\\
hspace*{2cm}
"
nid
=
self
.
shiftNote
(
self
.
getOctaveEtIDNote
(
n
),
self
.
shiftOctave
)
mw
=
self
.
boomwhackers
[
nid
]
result
+=
self
.
pointColore
(
mw
,
0
,
0
,
radius
)
result
+=
"
\\
end{tikzpicture}
"
result
+=
"
\\\\
\n
"
result
+=
"
\\\\
\n
"
if
not
beamer
:
if
not
beamer
:
result
+=
"
Prénom
"
result
+=
"
\\
hline
\n
"
for
n
in
notes
:
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
&
"
result
+=
"
}
\n
"
result
+=
"
\\
hspace*{2cm}
"
#result += " \\newline \n"
result
+=
"
\\\\
\n
"
if
not
beamer
:
result
+=
"
\\
hline
\n
"
result
+=
"
\\
end{tabular}
\n
"
result
+=
"
}
\n
"
result
+=
"
\\
newline
\n
\\
\n
"
result
+=
"
\\
caption{Représentation colorée des notes}
\n
"
result
+=
"
\\
caption{Représentation colorée des notes}
\n
"
result
+=
"
\\
end{table}
\n
"
result
+=
"
\\
end{table}
\n
"
...
@@ -428,7 +468,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -428,7 +468,7 @@ class GenerateurExercice(GammeTemperee):
if
beamer
:
if
beamer
:
result
+=
"
\\
frame{
"
result
+=
"
\\
frame{
"
result
+=
"
\\
frametitle{Représentation graphique}
"
result
+=
"
\\
frametitle{Représentation graphique}
\n
"
frequences
=
self
.
notesDansPartition
(
partitions
)
frequences
=
self
.
notesDansPartition
(
partitions
)
...
@@ -458,9 +498,9 @@ class GenerateurExercice(GammeTemperee):
...
@@ -458,9 +498,9 @@ class GenerateurExercice(GammeTemperee):
if
beamer
:
if
beamer
:
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
result
+=
"
}
"
result
+=
"
}
\n
"
result
+=
"
\\
frame{
"
result
+=
"
\\
frame{
\n
"
result
+=
"
\\
frametitle{Représentation graphique}
"
result
+=
"
\\
frametitle{Représentation graphique}
\n
"
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
result
+=
self
.
ensembleDesNotesGraphiques
(
frequences
,
radius
,
beamer
)
...
@@ -497,7 +537,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -497,7 +537,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
Cette partition n
'
est pas représentable sous forme de partition pour boomwhackers diatoniques.
"
result
+=
"
Cette partition n
'
est pas représentable sous forme de partition pour boomwhackers diatoniques.
"
if
beamer
:
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
return
result
def
partitionMusicale
(
self
,
partitions
,
beamer
=
False
):
def
partitionMusicale
(
self
,
partitions
,
beamer
=
False
):
...
@@ -539,7 +579,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -539,7 +579,7 @@ class GenerateurExercice(GammeTemperee):
if
note
[
0
]
!=
0
:
if
note
[
0
]
!=
0
:
result
+=
self
.
dureeToMusicTex
(
note
[
1
])
+
"
{
"
result
+=
self
.
dureeToMusicTex
(
note
[
1
])
+
"
{
"
result
+=
self
.
frequenceToMusicTeX
(
note
[
0
],
midOctave
)
result
+=
self
.
frequenceToMusicTeX
(
note
[
0
],
midOctave
)
result
+=
"
}
"
result
+=
"
}
\n
"
longueurCourante
+=
note
[
1
]
longueurCourante
+=
note
[
1
]
else
:
else
:
# TODO
# TODO
...
@@ -561,7 +601,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -561,7 +601,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
Le générateur d
'
exercice ne prend pas en charge cette partition.
"
result
+=
"
Le générateur d
'
exercice ne prend pas en charge cette partition.
"
if
beamer
:
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
return
result
...
@@ -783,7 +823,7 @@ class GenerateurExercice(GammeTemperee):
...
@@ -783,7 +823,7 @@ class GenerateurExercice(GammeTemperee):
result
+=
"
\\
end{tikzpicture}
"
result
+=
"
\\
end{tikzpicture}
"
if
beamer
:
if
beamer
:
result
+=
"
}
"
result
+=
"
}
\n
"
return
result
return
result
...
@@ -853,15 +893,24 @@ class GenerateurExercice(GammeTemperee):
...
@@ -853,15 +893,24 @@ class GenerateurExercice(GammeTemperee):
l_fichier
.
write
(
self
.
spectrogramme
(
partitions
,
True
))
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
.
partitionGraphique
(
partitions
,
True
))
l_fichier
.
write
(
self
.
partitionMusicale
(
partitions
,
True
))
l_fichier
.
write
(
self
.
partitionMusicale
(
partitions
,
True
))
if
nomSolution
!=
""
:
if
nomSolution
!=
""
:
result
=
"
\\
frame{
"
result
=
"
\\
frame{
\n
"
result
+=
"
\\
frametitle{Solution}
\n
"
result
+=
"
\\
frametitle{Solution}
\n
"
result
+=
"
\\
begin{center}\Large Cette mélodie s
'
appelle
"
+
nomSolution
+
"
\\
end{center}
"
result
+=
"
\\
begin{center}\Large Cette mélodie s
'
appelle
"
+
nomSolution
+
"
\\
end{center}
"
result
+=
"
}
"
result
+=
"
}
\n
"
l_fichier
.
write
(
result
)
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