Skip to content

Commit

Permalink
Merge pull request #190 from naomiaro/feat/effects
Browse files Browse the repository at this point in the history
Feat/effects
  • Loading branch information
naomiaro authored Feb 5, 2022
2 parents d1b625c + 7a2836e commit f462a87
Show file tree
Hide file tree
Showing 15 changed files with 2,007 additions and 2,818 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ I've written up some demos on github for the different [audio fade types](https:
![Screenshot](img/annotations.png?raw=true "Aeneas annotations adjust alignment json export")
(code for picture shown can be found in ghpages/\_examples/13annotations.html)


## Browser Support

Waveform Playlist requires webaudio in the browser to function correctly: [Can I Use?](http://caniuse.com/#search=webaudio)


## Installation

`npm install waveform-playlist --save`
Expand Down Expand Up @@ -230,6 +228,19 @@ var options = {
// If true annotation endpoints will remain linked when dragged
// if they were the same value before dragging started.
linkEndpoints: false,

// pass a custom function which will receive the mastergainnode for this playlist and the audio context's destination.
// if you pass a function, you must connect these two nodes to hear sound at minimum.
// if you need to clean something up when the graph is disposed, return a cleanup function. Waveform Playlist will cleanup the nodes passed as arguments.
effects: function (masterGainNode, destination) {
masterGainNode.connect(analyser);
masterGainNode.connect(destination);

// return function cleanup() {
// // if you create webaudio nodes that need to be cleaned up do that here
// // see the track effects example.
// };
},
},
};
```
Expand Down Expand Up @@ -316,7 +327,22 @@ var options = {
},

// value from -1 (full left pan) to 1 (full right pan)
stereoPan: 0
stereoPan: 0,

// pass a custom function which will receive the last graphnode for this track and the mastergainnode.
// if you pass a function, you must connect these two nodes to hear sound at minimum.
// if you need to clean something up when the graph is disposed, return a cleanup function. Waveform Playlist will cleanup the nodes passed as arguments.
effects: function(graphEnd, masterGainNode) {
var reverb = new Tone.Reverb(1.2);

Tone.connect(graphEnd, reverb);
Tone.connect(reverb, masterGainNode);

return function cleanup() {
reverb.disconnect();
reverb.dispose();
}
}
}
```

Expand Down
252 changes: 252 additions & 0 deletions dist/waveform-playlist/effects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
property="og:image"
content="https://raw.githubusercontent.com/naomiaro/waveform-playlist/master/img/stemtracks.png"
/>
<meta
property="og:image:height"
content="401"
/>
<meta
property="og:image:width"
content="1039"
/>

<title>
Tone.js Effects + Custom Webaudio Graphs
</title>
<meta
name="description"
content="Basic web audio single track mono display waveform editor. Play, stop, pause audio. Live seeking enabled."
/>

<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="/waveform-playlist/css/main.css">
<link
rel="canonical"
href="https://naomiaro.github.io/waveform-playlist/effects.html"
/>
<link rel="alternate" type="application/rss+xml" title="Waveform Playlist"
href="https://naomiaro.github.io/waveform-playlist/feed.xml">
<style>
.github-corner:hover .octo-arm,
.github-corner:focus .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0);
}
20%,
60% {
transform: rotate(-25deg);
}
40%,
80% {
transform: rotate(10deg);
}
}
@media (max-width: 500px) {
.github-corner:hover .octo-arm {
animation: none;
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
}
</style>
<script src="https://kit.fontawesome.com/ef69927139.js" crossorigin="anonymous"></script>
</head>


<body>
<script>
(function (i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
"script",
"//www.google-analytics.com/analytics.js",
"ga"
);

ga("create", "UA-62186746-1", "auto");
ga("send", "pageview");
</script>
<header class="site-header">
<ol class="breadcrumb">
<li><a href="/waveform-playlist/">Waveform Playlist</a></li>
<li class="mx-3 active">Tone.js Effects + Custom Webaudio Graphs</li>
</ol>
<a
href="https://github.com/naomiaro/waveform-playlist"
class="github-corner"
aria-label="View source on GitHub"
><svg
width="80"
height="80"
viewBox="0 0 250 250"
style="
fill: #151513;
color: #fff;
position: absolute;
top: 0;
border: 0;
right: 0;
"
aria-hidden="true"
>
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
style="transform-origin: 130px 106px"
class="octo-arm"
></path>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
></path></svg
></a>
</header>


<main class="container" title="demo">
<div class="wrapper">
<article class="post">
<header class="post-header">
<h1 class="post-title">Tone.js Effects + Custom Webaudio Graphs</h1>
<p class="lead">Add effects to each track or analyse the master output. Frequency bar graph code <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API">adapted from MDN</a>.</p>
</header>
<div class="post-content"><div id="top-bar" class="playlist-top-bar">
<div class="playlist-toolbar">
<div class="btn-group">
<button type="button" class="btn-pause btn btn-outline-warning" title="Pause">
<i class="fas fa-pause"></i>
</button>
<button type="button" class="btn-play btn btn-outline-success" title="Play">
<i class="fas fa-play"></i>
</button>
<button type="button" class="btn-stop btn btn-outline-danger" title="Stop">
<i class="fas fa-stop"></i>
</button>
<button
type="button"
class="btn-rewind btn btn-outline-success"
title="Rewind"
>
<i class="fas fa-fast-backward"></i>
</button>
<button
type="button"
class="btn-fast-forward btn btn-outline-success"
title="Fast forward"
>
<i class="fas fa-fast-forward"></i>
</button>
<button
type="button"
class="btn-record btn btn-outline-primary disabled"
title="Record"
>
<i class="fas fa-microphone"></i>
</button>
</div>

</div>
<div><canvas class="visualizer" width="1000" height="100"></canvas></div>
</div>
<div id="playlist"></div>
<form class="form-inline">
<label for="master-gain" class="mr-sm-2">Master Volume</label>
<input
type="range"
min="0"
max="100"
value="100"
class="master-gain form-control mr-sm-2"
id="master-gain"
/>

</form>
<form class="form-inline">
<select class="time-format custom-select mr-sm-2" aria-label="Time format selection">
<option value="seconds">seconds</option>
<option value="thousandths">thousandths</option>
<option value="hh:mm:ss">hh:mm:ss</option>
<option value="hh:mm:ss.u">hh:mm:ss + tenths</option>
<option value="hh:mm:ss.uu">hh:mm:ss + hundredths</option>
<option value="hh:mm:ss.uuu" selected="selected">hh:mm:ss + milliseconds</option>
</select>
<label class="sr-only" for="audio_start">Start of audio selection</label>
<input type="text" class="audio-start form-control mr-sm-2" id="audio_start">
<label class="sr-only" for="audio_end">End of audio selection</label>
<input type="text" class="audio-end form-control mr-sm-2" id="audio_end">
<span class="audio-pos" aria-label="Audio position">00:00:00.0</span>
</form>

<div class="track-drop"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.7.77/Tone.js" integrity="sha512-gwSDP1iEKl4KG0wi3N89RAJU91s78jb/TGC6lsbF5IyR2c19Rn7Jl1icK4K4kUiJNwQUEPI7o98T+GJVWNuvIQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</div>
</article>
</div>

</main>
<aside class="container mt-5"><h2>Sponsors</h2>
<p><a href="https://moises.ai/" rel="sponsored noopener" target="_blank"><img src="img/logos/moises-ai.svg" width="120" /></a></p>
<p>
The annotation plugin has been sponsored by a fond Italian TED volunteer transcriber hoping to make the transcription process of TEDx talks easier and more fun.
</p>
<p class="text-center"><iframe src="https://github.com/sponsors/naomiaro/card" title="Sponsor naomiaro" height="240" width="340" style="border: 0;"></iframe></p>
</aside>

<footer class="px-3">

<p>Music: <cite>Starlight</cite> by Muse</p>


<p>
Waveform Playlist originally written for
<a href="https://www.sourcefabric.org/en/airtime">Airtime</a> at
<a href="https://www.sourcefabric.org">Sourcefabric</a>
</p>
<p>Licensed under the MIT License</p>
</footer>


<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>
<script type="text/javascript" src="js/waveform-playlist.js"></script>
<script type="text/javascript" src="js/effects.js"></script>
<script type="text/javascript" src="js/emitter.js"></script>


</body>
</html>
7 changes: 7 additions & 0 deletions dist/waveform-playlist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ <h3>
<p class="lead">Render the waveform in "bars".</p>
</li>

<li>
<h3>
<a class="post-link" href="/waveform-playlist/effects.html">Tone.js Effects + Custom Webaudio Graphs</a>
</h3>
<p class="lead">Add effects to each track or analyse the master output. Frequency bar graph code <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API">adapted from MDN</a>.</p>
</li>

<li>
<h3>
<a class="post-link" href="/waveform-playlist/web-audio-editor.html">Full Waveform Editor</a>
Expand Down
29 changes: 0 additions & 29 deletions dist/waveform-playlist/js/bars.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
var userMediaStream;
var playlist;
var constraints = { audio: true };

navigator.getUserMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);

function gotStream(stream) {
userMediaStream = stream;
playlist.initRecorder(userMediaStream);
$(".btn-record").removeClass("disabled");
}

function logError(err) {
console.error(err);
}

playlist = WaveformPlaylist.init({
container: document.getElementById("playlist"),
Expand All @@ -32,16 +15,4 @@ playlist.load([
}
]).then(function() {
//can do stuff with the playlist.

if (navigator.mediaDevices) {
navigator.mediaDevices.getUserMedia(constraints)
.then(gotStream)
.catch(logError);
} else if (navigator.getUserMedia && 'MediaRecorder' in window) {
navigator.getUserMedia(
constraints,
gotStream,
logError
);
}
});
Loading

0 comments on commit f462a87

Please sign in to comment.