All Projects → petamoriken → PxtoneJS

petamoriken / PxtoneJS

Licence: MIT license
Play Pxtone Collage files in Web Audio API.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to PxtoneJS

R Audio
A library of React components for building Web Audio graphs.
Stars: ✭ 129 (+303.13%)
Mutual labels:  web-audio
Audioworklet Polyfill
🔊 Polyfill AudioWorklet using the legacy ScriptProcessor API.
Stars: ✭ 179 (+459.38%)
Mutual labels:  web-audio
extendable-media-recorder
An extendable drop-in replacement for the native MediaRecorder.
Stars: ✭ 123 (+284.38%)
Mutual labels:  web-audio
Fetch Stream Audio
Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs
Stars: ✭ 153 (+378.13%)
Mutual labels:  web-audio
Tonejs Instruments
A small instrument sample library with quick-loader for tone.js
Stars: ✭ 172 (+437.5%)
Mutual labels:  web-audio
Audion
Audion (Web Audio Inspector) is a Chrome extension that adds a Web Audio panel to Developer Tools. This panel visualizes the web audio graph in real-time and lets users inspect nodes.
Stars: ✭ 230 (+618.75%)
Mutual labels:  web-audio
Freedrum.js
Interact with the browser using the Freedrum sensors in JavaScript
Stars: ✭ 115 (+259.38%)
Mutual labels:  web-audio
chords
Text-based chord progression editor
Stars: ✭ 25 (-21.87%)
Mutual labels:  web-audio
Audiomotion.js
High-resolution real-time spectrum analyzer and music player using Web Audio and Canvas APIs.
Stars: ✭ 177 (+453.13%)
Mutual labels:  web-audio
Tonalhub
Make your GitHub repository sing. Tonalhub will take the last year's commit activity and play it with web audio.
Stars: ✭ 18 (-43.75%)
Mutual labels:  web-audio
Guitarstack
Digital guitar effects right in your browser!
Stars: ✭ 164 (+412.5%)
Mutual labels:  web-audio
Wax
An experimental, JSX-compatible renderer for the Web Audio API
Stars: ✭ 171 (+434.38%)
Mutual labels:  web-audio
I dropped my phone the screen cracked
web audio, cracked.
Stars: ✭ 245 (+665.63%)
Mutual labels:  web-audio
Tone.js
A Web Audio framework for making interactive music in the browser.
Stars: ✭ 11,352 (+35375%)
Mutual labels:  web-audio
angular-audio-context
An Angular wrapper for the Web Audio API's AudioContext.
Stars: ✭ 20 (-37.5%)
Mutual labels:  web-audio
Mecca
Animated music editor in Clojurescript/re-frame
Stars: ✭ 125 (+290.63%)
Mutual labels:  web-audio
Timidity
Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
Stars: ✭ 221 (+590.63%)
Mutual labels:  web-audio
ember-audio
An Ember addon that makes working with the Web Audio API super EZ.
Stars: ✭ 33 (+3.13%)
Mutual labels:  web-audio
unmute-ios-audio
Enable/unmute WebAudio on iOS, even while mute switch is on
Stars: ✭ 96 (+200%)
Mutual labels:  web-audio
voder
An emulation of the Voder Speech Synthesizer.
Stars: ✭ 19 (-40.62%)
Mutual labels:  web-audio





PxtoneJS
Play Pxtone Collage files in Web Audio API.





License Github issues Dependency Status
npm Version npm Downloads release Version release Downloads

Demo

PxtoneJS Demo
※ JavaScript は ES6 で書いており、 Babel を使って ES5 のコードにトランスパイルして実行しています。そのままブラウザにコードを移してもおそらく動きませんので注意してください。

Install & Require

PxtoneJS releasespxtnDecoder releases から Pxtone.jspxtnDecoder.js を適当な場所に保存して

<script src="DEST/TO/Pxtone.js"></script>
<script src="DEST/TO/pxtnDecoder.js"></script>

としてください。
デコーダーを Web Worker として使う場合(推奨)は

<script src="DEST/TO/Pxtone.js"></script>
<script>
	var pxtnDecoder = new Worker("DEST/TO/pxtnDecoder.js");
</script>

としてください。

Initialize

以下のように初期化します。

var pxtone = new Pxtone();
pxtone.decoder = pxtnDecoder;

How to Use

ブラウザ上で Pxtone Collage ファイルを再生するには、XMLHttpRequestFetch API, File API などで Pxtone Collage Project ファイル(拡張子 .ptcop)か Pxtone Tune ファイル(拡張子 .pttune) の ArrayBuffer を取得する必要があります。仮に arrayBuffer という変数に得た Pxtone Collage ファイル の ArrayBuffer を入れた場合、以下のようにして AudioBuffer を得ることが出来ます。

var ctx = new (window.AudioContext || window.webkitAudioContext)();
pxtone.decodePxtoneData(ctx, arrayBuffer).then(function(obj) {
  var audioBuffer = obj.buffer;
  var data = obj.data;
});

得た AudioBuffer を再生するには AudioBufferSourceNode を使います。詳しくは MDN の Web Audio APIの利用AudioContext.createBufferSource() を参考にしてください。

API

AudioBuffer を作る

  • Pxtone#decodeNoiseData(ctx: AudioContext, buffer: ArrayBuffer, channel: number = 2, sampleRate: number = null, bitsPerSample: number = 16): Promise<{buffer: AudioBuffer, data: null}>

    • Pxtone Noise ファイル(拡張子 .ptnoise)を AudioBuffer に変換します。
    • channel1, 2 の値を、bitsPerSample8, 16 の値のみ取ります。
    • sampleRate11025, 22050, 44100, null の値のみ取ります。null のときは第一引数の ctx のプロパティである ctx.sampleRate の値を使います。ただし、それが 11025, 22050, 44100 のいずれでもない場合は 44100 とします。
  • Pxtone#decodePxtoneData(ctx: AudioContext, buffer: ArrayBuffer, channel: number = 2, sampleRate: number = null, bitsPerSample: number = 16): Promise<{buffer: AudioBuffer, data: Object}>

    • Pxtone Collage Project ファイル(拡張子 .ptcop)と Pxtone Tune ファイル(拡張子 .pttune)を AudioBuffer に変換します。

    • channel1, 2 の値を、bitsPerSample8, 16 の値のみ取ります。

    • sampleRate11025, 22050, 44100, null の値のみ取ります。null のときは第一引数の ctx のプロパティである ctx.sampleRate の値を使います。ただし、それが 11025, 22050, 44100 のいずれでもない場合は 44100 とします。

    • Pxtone#decodeNoiseData とは違い、返り値の Promisedata: Object を持ちます。data: Object は以下の様なプロパティを持ちます。

      • title: string: ファイルが持つタイトルの文字列です。
      • comment: string: ファイルが持つコメントの文字列です。
      • loopStart: number: ループ初めの位置です(Web Audio API の AudioBufferSourceNode に与えて使います) 。
      • loopEnd: number: ループ終わり位置です(Web Audio API の AudioBufferSourceNode に与えて使います)。

Wave の ArrayBuffer を作る

  • Pxtone#decodeNoise(buffer: ArrayBuffer, channel: number = 2, sampleRate: number = null, bitsPerSample: number = 16): Promise<{buffer: ArrayBuffer, data: null}>

    • Pxtone Noise ファイル(拡張子 .ptnoise)を Wave の ArrayBuffer に変換します。
    • 引数については Pxtone#decodeNoiseData と同じです。ただし sampleRatenull のときは 44100 として扱います。
  • Pxtone#decodePxtone(buffer: ArrayBuffer, channel: number = 2, sampleRate: number = null, bitsPerSample: number = 16): Promise<{buffer: ArrayBuffer, data: Object}>

    • Pxtone Collage Project ファイル(拡張子 .ptcop)と Pxtone Tune ファイル(拡張子 .pttune)を Wave の ArrayBuffer に変換します。
    • 引数については Pxtone#decodePxtoneData と同じです。ただし sampleRatenull のときは 44100 として扱います。

License & Dependencies

under MIT License.

Support

何か問題が起きた場合は issues に投稿してください。
また簡単な使い方の質問などは @printf_moriken に気軽にどうぞ。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].