Skip to content

Instantly share code, notes, and snippets.

@ruzz311
Last active March 9, 2017 05:34
Show Gist options
  • Save ruzz311/74afefef6b95fba5b5de74cf77e79b5d to your computer and use it in GitHub Desktop.
Save ruzz311/74afefef6b95fba5b5de74cf77e79b5d to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import { Oscillator } from 'ember-audio';
import { MusicalIdentity } from 'ember-audio/mixins';
const MusicallyAwareOscillator = Oscillator.extend(MusicalIdentity);
export default Ember.Component.extend({
items: [
415.3,
215.3,
915.3
],
audio: Ember.inject.service(),
file: 'http://sethbrasile.github.io/ember-audio/Eb5.mp3',
initAudioFile: Ember.computed('file', {
get() {
const file = this.get('file');
debugger;
// Eb5.mp3 is an mp3 file located in the "public" folder
this.get('audio').load(file).asSound('piano-note');
//http://sethbrasile.github.io/ember-audio/#/synthesis
}
}),
actions: {
playSound() {
debugger;
//this.get('audio').getSound('piano-note').play();
console.log(this.get('audio'))
debugger;
/*
const audioContext = this.get('audio.audioContext');
const oscillator = MusicallyAwareOscillator.create({
audioContext,
frequency: arguments[0] || 415.3
});
console.log(oscillator.get('identifier'));
*/
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Funtime with Ember'
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('audio', {path: '/'})
//this.route('audio', {path: '/audio'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return {
my: "test"
}
}
});
<h1>Welcome to {{appName}}</h1>
<ul>
<li>{{link-to 'audio' 'audio'}}</li>
</ul>
<br>
<br>
{{outlet}}
<br>
<br>
{{yield}}
{{#each items as |item|}}
<button {{action 'playSound' item}}>yay.</button>
{{/each}}
{
"version": "0.11.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0",
"ember-audio": "0.0.0-alpha.3"
},
"addons": {
"ember-audio": "0.0.0-alpha.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment