mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-28 12:33:12 +00:00
parent
62568bd4ac
commit
3aa76d19c8
15 changed files with 39 additions and 17 deletions
|
@ -22,6 +22,29 @@ GUI.StartButton.prototype.buttonClicked = function(){
|
||||||
this.callback();
|
this.callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a start button for mobile browsers which require a touchstart event
|
||||||
|
* to start the audio
|
||||||
|
*/
|
||||||
|
GUI.MobileStart = function(callback){
|
||||||
|
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||||
|
this.element = $("<div>", {"class" : "StartButton"})
|
||||||
|
.appendTo("#Container");
|
||||||
|
this.button = $("<button>")
|
||||||
|
.button({label: "\u25B6"})
|
||||||
|
.click(this.buttonClicked.bind(this))
|
||||||
|
.appendTo(this.element);
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GUI.MobileStart.prototype.buttonClicked = function(){
|
||||||
|
this.element.fadeTo(500, 0, function(){
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
this.callback();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tone.Envelope GUI
|
* Tone.Envelope GUI
|
||||||
* @param {jQuery} container the jQuery object to put the gui in
|
* @param {jQuery} container the jQuery object to put the gui in
|
||||||
|
|
|
@ -48,16 +48,14 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.StartButton(function(){
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
Tone.startMobile();
|
|
||||||
panner.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
var container = $("#Content");
|
var container = $("#Content");
|
||||||
|
|
||||||
new GUI.Checkbox(container, function(on){
|
new GUI.Checkbox(container, function(on){
|
||||||
if (on){
|
if (on){
|
||||||
sine.start();
|
sine.start();
|
||||||
|
panner.start();
|
||||||
} else {
|
} else {
|
||||||
sine.stop();
|
sine.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
var content = $("#Content");
|
var content = $("#Content");
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
// new GUI.StartButton(Tone.startMobile);
|
// new GUI.MobileStart(Tone.startMobile);
|
||||||
|
|
||||||
$("#tabs").tabs();
|
$("#tabs").tabs();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
var container = $("#Content");
|
var container = $("#Content");
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
//sliders for the envelope controls
|
//sliders for the envelope controls
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
|
|
||||||
$("#tabs").tabs();
|
$("#tabs").tabs();
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
var content = $("#Content");
|
var content = $("#Content");
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
|
|
||||||
new GUI.Checkbox(content, function(on){
|
new GUI.Checkbox(content, function(on){
|
||||||
if (on){
|
if (on){
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
|
|
||||||
$("#tabs").tabs();
|
$("#tabs").tabs();
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
/* globals Tone, GUI */
|
/* globals Tone, GUI */
|
||||||
|
|
||||||
var noise = new Tone.Noise();
|
var noise = new Tone.Noise();
|
||||||
|
noise.setVolume(-10);
|
||||||
noise.toMaster();
|
noise.toMaster();
|
||||||
|
|
||||||
var noiseTypes = ["white", "brown", "pink"];
|
var noiseTypes = ["white", "brown", "pink"];
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
|
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
new GUI.Momentary($("#Button"), function(){
|
new GUI.Momentary($("#Button"), function(){
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
var content = $("#Content");
|
var content = $("#Content");
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.Checkbox(content, function(on){
|
new GUI.Checkbox(content, function(on){
|
||||||
if (on){
|
if (on){
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
new GUI.Momentary($("#Content"), function(on){
|
new GUI.Momentary($("#Content"), function(on){
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
new GUI.Momentary($("#Content"), function(on){
|
new GUI.Momentary($("#Content"), function(on){
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
var content = $("#Content");
|
var content = $("#Content");
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
//the transport controls
|
//the transport controls
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
// GUI //
|
// GUI //
|
||||||
|
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
|
|
||||||
var container = $("#Content");
|
var container = $("#Content");
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUI.StartButton(Tone.startMobile);
|
new GUI.MobileStart(Tone.startMobile);
|
||||||
new GUI.TopBar(Tone);
|
new GUI.TopBar(Tone);
|
||||||
|
|
||||||
var startButton = $("#StartButton");
|
var startButton = $("#StartButton");
|
||||||
|
|
Loading…
Reference in a new issue