using tone.js within angular6

蓝咒 提交于 2019-12-05 18:37:28

If you are using angular-cli, you could try adding the ToneJS library to your angular.json as an external script

projects
- architect
  - build
    - scripts
      - [ ..., "node_modules/path/to/Tone.js"]

if you dont have a typings.d.ts file at src/typings.d.ts, create this file and add this line declare var Tone: any;

Now, ToneJs should be available for you to use throughout the app as a Global variable. So you can use it like this:

import { Component } from '@angular/core';

@Component({
  selector: 'app-player',
  templateUrl: './player.component.html',
  styleUrls: ['./player.component.css']
})
export class PlayerComponent {  
    constructor() { 
        // const loop = new Tone.Loop((time) => { 
            // do something 
        }
    }
}

Someone named Dylan Lawrence created a nice starter I found while googling on this topic this morning. Super helpful!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!