Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Descamps
projet_IA04
Commits
3ebd2463
Commit
3ebd2463
authored
Dec 29, 2021
by
Louis Soto
Browse files
levels
parent
c1967561
Changes
1
Hide whitespace changes
Inline
Side-by-side
Boid/agent/music/music.go
View file @
3ebd2463
...
...
@@ -82,6 +82,7 @@ func (musicAgent *MusicAgent) Start() {
if
quit
{
esc
=
true
}
if
changed
{
screen
.
Clear
()
ap
.
draw
(
screen
)
...
...
@@ -98,6 +99,7 @@ func (musicAgent *MusicAgent) Start() {
sr
:=
ap
.
streamer
.
Position
()
amplitude
:=
ap
.
samples
[
sr
]
speaker
.
Unlock
()
if
amplitude
>
0.5
{
ap
.
sync
<-
"very hard drop"
}
else
if
amplitude
>
0.3
{
...
...
@@ -138,11 +140,11 @@ type audioPanel struct {
sync
chan
string
}
func
newAudioPanel
(
sampleRate
beep
.
SampleRate
,
streamer
beep
.
StreamSeeker
,
samples
[]
pkg
.
Frame
,
c
chan
string
)
*
audioPanel
{
func
newAudioPanel
(
sampleRate
beep
.
SampleRate
,
streamer
beep
.
StreamSeeker
,
samples
[]
pkg
.
Frame
,
c
1
chan
string
)
*
audioPanel
{
ctrl
:=
&
beep
.
Ctrl
{
Streamer
:
beep
.
Loop
(
-
1
,
streamer
)}
resampler
:=
beep
.
ResampleRatio
(
4
,
1
,
ctrl
)
volume
:=
&
effects
.
Volume
{
Streamer
:
resampler
,
Base
:
2
}
return
&
audioPanel
{
sampleRate
,
streamer
,
ctrl
,
resampler
,
volume
,
samples
,
c
}
return
&
audioPanel
{
sampleRate
,
streamer
,
ctrl
,
resampler
,
volume
,
samples
,
c
1
}
}
func
(
ap
*
audioPanel
)
play
()
{
...
...
@@ -210,7 +212,6 @@ func (ap *audioPanel) handle(event tcell.Event) (changed, quit bool) {
switch
event
:=
event
.
(
type
)
{
case
*
tcell
.
EventKey
:
if
event
.
Key
()
==
tcell
.
KeyESC
{
// panic("esc")
return
false
,
true
}
...
...
@@ -269,6 +270,39 @@ func (ap *audioPanel) handle(event tcell.Event) (changed, quit bool) {
ap
.
resampler
.
SetRatio
(
ap
.
resampler
.
Ratio
()
*
16
/
15
)
speaker
.
Unlock
()
return
true
,
false
// raccourcis secret par la channel de la musique:
case
'l'
:
// commenter lock/unlock si on ne veux pas que la musique s'arrete
speaker
.
Lock
()
ap
.
sync
<-
"1"
time
.
Sleep
((
1
*
time
.
Second
))
speaker
.
Unlock
()
return
true
,
false
case
'o'
:
speaker
.
Lock
()
ap
.
sync
<-
"2"
time
.
Sleep
((
1
*
time
.
Second
))
speaker
.
Unlock
()
return
true
,
false
case
'u'
:
speaker
.
Lock
()
ap
.
sync
<-
"3"
time
.
Sleep
((
1
*
time
.
Second
))
speaker
.
Unlock
()
return
true
,
false
case
'i'
:
speaker
.
Lock
()
ap
.
sync
<-
"4"
time
.
Sleep
((
1
*
time
.
Second
))
speaker
.
Unlock
()
return
true
,
false
case
'j'
:
speaker
.
Lock
()
ap
.
sync
<-
"5"
time
.
Sleep
((
1
*
time
.
Second
))
speaker
.
Unlock
()
return
true
,
false
}
}
return
false
,
false
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment