首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Angular中使用Tone.js UI显示键盘?

如何在Angular中使用Tone.js UI显示键盘?
EN

Stack Overflow用户
提问于 2019-05-27 14:52:06
回答 1查看 275关注 0票数 0

Angular 7应用程序中,我安装了Tone.js依赖项:

代码语言:javascript
复制
npm install tone
npm install @tonejs/ui

我可以演奏音符,并且我想使用在这个fiddle中看到的tone-keyboard元素来显示键盘

我的synth.component.html文件包含:

代码语言:javascript
复制
<tone-demo autoplay>
  <tone-keyboard octaves="3"></tone-keyboard>
</tone-demo>

我的synth.component.ts文件包含:

代码语言:javascript
复制
import { Component, OnInit } from '@angular/core';
import Tone from 'tone';

但我得到以下错误:

代码语言:javascript
复制
Error: : 'tone-keyboard' is not a known element:

我应该在synth.component.ts文件中有一些额外的import语句吗?

EN

回答 1

Stack Overflow用户

发布于 2019-05-27 14:56:18

代码语言:javascript
复制
var synth = new Tone.Synth().toMaster()

//play a 'C' for one 8th note
synth.triggerAttackRelease('C4', '8n')


var synth = new Tone.AMSynth().toMaster()

startNote = (event) => {
   synth.triggerAttack(event.target)
}

endNote = (event) => {
   synth.triggerRelease()
}

//Mouse click starts the note 
<Button onMouseDown={this.startNote}/>

//Mouse click ends the note 
<Button onMouseUp={this.endNote}/>





var jakeSynth = new Tone.Synth({
  oscillator : {
    type : 'fmsquare',
        modulationType : 'sawtooth',
        modulationIndex : 3,
        harmonicity: 3.4
  },
  envelope : {
    attack : 0.001,
        decay : 0.1,
        sustain: 0.1,
        release: 0.1
  }
}).toMaster() 

jakeSynth.triggerAttackRelease('B2', '8n')


For more detail visit link:-
https://tonejs.github.io/
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56321024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档