Skip to content

Instantly share code, notes, and snippets.

@naoyashiga
Created March 20, 2016 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoyashiga/074e11c3103f321dfcfb to your computer and use it in GitHub Desktop.
Save naoyashiga/074e11c3103f321dfcfb to your computer and use it in GitHub Desktop.
p5.js sound test
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
</style>
<script src="http://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.22/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.23/addons/p5.sound.min.js"></script>
<script src="sketch.js"></script>
</head>
<body>
</body>
</html>
var sketch = function($p) {
var mySound;
$p.preload = function() {
mySound = $p.loadSound('symphony.mp3');
};
$p.setup = function() {
$p.createCanvas(window.innerWidth, window.innerHeight);
mySound.setVolume(0.1);
mySound.play();
};
$p.draw = function() {
$p.background(0);
$p.fill(255);
};
};
var myp5 = new p5(sketch);
@naoyashiga
Copy link
Author

folder directory

  • soundTest
    • sketch.js
    • index.html
    • symphony.mp3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment