Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
raspberry-pi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LAKHAL MAYSSA p2308653
raspberry-pi
Commits
350a8ebe
Commit
350a8ebe
authored
1 month ago
by
LAKHAL MAYSSA p2308653
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://forge.univ-lyon1.fr/p2308653/raspberry-pi
parents
9fa6c8d2
7e0b57da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/index.html
+2
-2
2 additions, 2 deletions
frontend/index.html
frontend/script2.js
+90
-0
90 additions, 0 deletions
frontend/script2.js
with
92 additions
and
2 deletions
frontend/index.html
+
2
−
2
View file @
350a8ebe
...
...
@@ -10,12 +10,12 @@
<div
class=
"container"
>
<h1
class=
"loopStation"
>
Loop Station
</h1>
<div
id=
"tracks-container"
></div>
<button
id=
"add-track"
>
A
jouter une piste
</button>
<button
id=
"add-track"
>
A
dd Audio Track
</button>
<input
type=
"file"
id=
"file-input"
accept=
"audio/*"
style=
"display: none;"
/>
</div>
<script
src=
"http://unpkg.com/tone"
></script>
<script
src=
"script.js"
></script>
<script
src=
"script
2
.js"
></script>
</body>
</html>
This diff is collapsed.
Click to expand it.
frontend/script2.js
0 → 100644
+
90
−
0
View file @
350a8ebe
function
main
(){
document
.
addEventListener
(
"
DOMContentLoaded
"
,
()
=>
{
const
tracksContainer
=
document
.
getElementById
(
"
tracks-container
"
);
const
addTrackButton
=
document
.
getElementById
(
"
add-track
"
);
const
fileInput
=
document
.
getElementById
(
"
file-input
"
);
function
createTrack
(
audioFile
=
null
)
{
const
track
=
document
.
createElement
(
"
div
"
);
track
.
classList
.
add
(
"
track
"
);
const
waveform
=
document
.
createElement
(
"
div
"
);
waveform
.
classList
.
add
(
"
waveform
"
);
const
playhead
=
document
.
createElement
(
"
div
"
);
playhead
.
classList
.
add
(
"
playhead
"
);
waveform
.
appendChild
(
playhead
);
const
playButton
=
document
.
createElement
(
"
button
"
);
playButton
.
textContent
=
"
Play
"
;
const
muteButton
=
document
.
createElement
(
"
button
"
);
muteButton
.
textContent
=
"
Mute
"
;
const
player
=
new
Tone
.
Player
(
audioFile
).
toDestination
();
player
.
loop
=
true
;
let
animationFrame
;
playButton
.
addEventListener
(
"
click
"
,
()
=>
{
if
(
player
.
state
===
"
started
"
)
{
player
.
stop
();
playButton
.
textContent
=
"
Play
"
;
cancelAnimationFrame
(
animationFrame
);
}
else
{
player
.
start
();
playButton
.
textContent
=
"
Stop
"
;
const
startTime
=
Tone
.
now
();
const
duration
=
player
.
buffer
.
duration
;
function
updatePlayhead
()
{
const
elapsedTime
=
Tone
.
now
()
-
startTime
;
const
progress
=
(
elapsedTime
%
duration
)
/
duration
;
playhead
.
style
.
transform
=
`translateX(
${
progress
*
100
}
%)`
;
animationFrame
=
requestAnimationFrame
(
updatePlayhead
);
}
updatePlayhead
();
}
});
muteButton
.
addEventListener
(
"
click
"
,
()
=>
{
player
.
mute
=
!
player
.
mute
;
muteButton
.
textContent
=
player
.
mute
?
"
Unmute
"
:
"
Mute
"
;
});
track
.
appendChild
(
waveform
);
track
.
appendChild
(
playButton
);
track
.
appendChild
(
muteButton
);
tracksContainer
.
appendChild
(
track
);
}
addTrackButton
.
addEventListener
(
"
click
"
,
()
=>
{
fileInput
.
click
();
});
fileInput
.
addEventListener
(
"
change
"
,
(
event
)
=>
{
const
file
=
event
.
target
.
files
[
0
];
if
(
file
)
{
const
reader
=
new
FileReader
();
reader
.
onload
=
(
e
)
=>
{
const
audioUrl
=
e
.
target
.
result
;
createTrack
(
audioUrl
);
};
reader
.
readAsDataURL
(
file
);
}
});
});
const
osc
=
new
Tone
.
Oscillator
().
toDestination
().
start
();
// a scheduleable signal which can be connected to control an AudioParam or another Signal
const
signal
=
new
Tone
.
Signal
({
value
:
"
C4
"
,
units
:
"
frequency
"
}).
connect
(
osc
.
frequency
);
// the scheduled ramp controls the connected signal
signal
.
rampTo
(
"
C2
"
,
4
,
"
+0.5
"
);
console
.
log
(
signal
);
}
main
();
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