Code Monkey home page Code Monkey logo

surikov / webaudiofont Goto Github PK

View Code? Open in Web Editor NEW
863.0 31.0 90.0 152.39 MB

Use full GM set of musical instruments to play MIDI and single sounds or effects. Support for reverberation and equaliser. No plugins, no Flash. Pure HTML5 implementation compatible with desktop and mobile browser. See live examples.

Home Page: https://surikov.github.io/webaudiofont/

License: GNU General Public License v3.0

JavaScript 2.35% TypeScript 17.48% CSS 10.84% HTML 69.33%
sound drums soundfont midi player sampler wavetable music synth instrument

webaudiofont's People

Contributors

arokia16 avatar chrislo avatar page200 avatar raisingagent avatar surikov avatar yaoer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webaudiofont's Issues

Run locally

My apologies, if this is not the place for these questions.
May I run locally? We have a lot of places with bad or without internet.
I really appreciate all the help that you can send me.

suggestion: loader: load fonts with fetch/xhr instead of script tag

var r = document.createElement('script');
r.setAttribute("type", "text/javascript");
r.setAttribute("src", filePath);
document.getElementsByTagName("head")[0].appendChild(r);
this.decodeAfterLoading(audioContext, variableName);

Maybe it is better to load audio fonts with fetch or xhr, instead of load them in script tag.
Loader can also avoid setting global variables like window[name] in this way.
It may require changes on all audio fonts, though.

Examples not working on Chromium

It seems like all examples stopped working when using Chromium on Ubuntu/GNU Linux. Most probably this is due to the Web Audio autoplay policy which was re-enabled in Chrome 71. On Firefox the examples run just fine.

Dynamic loading

When I use Dynamic loading, i set a val for the notes, The notes play great.
I have a button to play a sound sample.
However when i invoke the Dynamic loading and try to change instruments. the current instrument will continue to play everytime i hit the Play button until i change the notes varible to a new sound.
then the change of instrument takes affect.
my play button calls the start() function, so the start() function continues to play the same instrument, until a change occurs to the beats.

is there a way to make the instrument change right away so that when i start() again the same notes will play with the new instrument.

var instr=null;
var AudioContextFunc = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContextFunc();
var player=new WebAudioFontPlayer();
function changeInstrument(path,name){
player.loader.startLoad(audioContext, path, name);
player.loader.waitLoad(function () {
instr=window[name];
});
}
changeInstrument('https://surikov.github.io/webaudiofontdata/sound/0290_Aspirin_sf2_file.js','_tone_0290_Aspirin_sf2_file');

Playing MIDI

Hi.

I have midi files stored in AWS S3 and would like to play those files on my website using webaudiofont.

I am, however, not entirely sure how to do it.

How do I need to adjust the following code in order to get it to work?

Thank you very much for your help!

_

<script src='https://surikov.github.io/webaudiofont/npm/dist/WebAudioFontPlayer.js'></script>
<script src='https://surikov.github.io/webaudiofontdata/sound/0250_SoundBlasterOld_sf2.js'></script>
<script>
var AudioContextFunc = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContextFunc();
var player=new WebAudioFontPlayer();
player.loader.decodeAfterLoading(audioContext, '_tone_0250_SoundBlasterOld_sf2');
function play(){
player.queueWaveTable(audioContext, audioContext.destination
, _tone_0250_SoundBlasterOld_sf2, 0, 12*4+7, 2);
return false;
}
</script>


Play!


_

Random empty buffer at the first time the note is played

Hello,

I have a weird issue about empty buffer when i played a note for the first time (it's random issue, like 1/5).

empybuffer

If i replay this note after that, this work fine.

This issue appear on all browsers (Chrome, Firefox, Safari) and all device (desktop, tablet, mobile).
I create 6 instances of WebAudioFontPlayer (one per instrument, like MIDI channel) like this :

this.audioContext = ctx;
this.player = new WebAudioFontPlayer();

if(this.supportOGG == true){
                this.player.loader.startLoad(this.audioContext, this.listeInstruments[preset]["url"], _this.listeInstruments[preset]["object"]);
		this.player.loader.waitOrFinish(_this.listeInstruments[preset]["object"],function(){
					_this.selectedPreset = window[_this.listeInstruments[preset]["object"]];
					_this.selectedPresetString = preset;
		});
}else{
	var head = document.getElementsByTagName("head")[0];
	var script = document.createElement("script");
	script.src = this.listeInstruments[preset]["url"];
	var done = false;
	script.onload = script.onreadystatechange = function() { 
			// attach to both events for cross browser finish detection:
		if ( !done && (!this.readyState ||this.readyState == "loaded" || this.readyState == "complete") ) {
			done = true;
			_this.selectedPreset = window[_this.listeInstruments[preset]["object"]];
			_this.selectedPresetString = preset;
			// cleans up a little memory:
			script.onload = script.onreadystatechange = null;
			head.removeChild(script);
		}
	};
	head.appendChild(script);
}

Thank in advance ;)

How do I show the MetaEvent Track Name in the Midi Demo?

On screen in the Midi Demo, I want to show the (event meta) track name next to the instrument.
MIDIEvents.EVENT_META_TRACK_NAME:

I haven't yet found it in the objects (in the inspector with console.log) when I am running play.html.

Hope you can help me find the track name.
I have found references of .EVENT_META_TRACK_NAME in midifile.js but it's not clear how I can get these into the objects of play.html.

Thank you for your help!
René

I made this little website using your library. One question.

Hi, my approach is very similar to the midi keyboard / dynamig loading example but with midi in / out selection.
thanks for your work, nice library.
https://webmidi.handmadeproductions.de/

A question: How can I play drums like gm MIDI, so that each pitch plays a different drum instrument?
Like loading this drum sound bank at once: https://surikov.github.io/webaudiofontdata/sound/drums_0_FluidR3_GM_sf2_fileStandard.html
Or do I need to load every sound seperately or change it with the pitch?
I think I need to find out how the MIDI player example works, because it seems to play every intended drum sound and does also find the right instruments.

And another Question: Is there a way to select the 128 sounds of a soundbank, and perhaps to switch the bank seperately (like it is done with gm MIDI too)? Then it would be possible to select the instrument with MIDI program change.

Is midi effects like Volume Control, PitchBend and Panning supported?

Is your feature request related to a problem? Please describe.
We are building a web-based DAW kind of application. We like your library. However, the example you have developed does not showcase effects like pitch band, panning, and message-based volume control. Is this library supports that? If not, do you have plan to support anytime sooner?

Repeated sound doesn't works in Safari (iOS and macOS)

All sounds played only one time.
Tested with: desktop (macOS 10.11.6) Safari (9.1.3) and IOS (10.1) Safari.

Log:
[Log] WebAudioFont Player v1.06 (WebAudioFontPlayer.js, line 1)
[Log] load _tone_Accoustic_32Bsaccousticbs_461_460_45127 (32.0.Accoustic_32Bsaccousticbs_461_460_45127.js, line 1)
[Error] InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable. stop (WebAudioFontPlayer.js:89) findEnvelope (WebAudioFontPlayer.js:89) queueWaveTable (WebAudioFontPlayer.js:16) global code (WebAudioFontExampleSimple.html:1)

Звук в примерах проигрывается только один раз, повторное нажатие вызывает ошибку.

Problem loading instruments while running

Hi,

I'm just starting with web applications development and i can't find a way to figure out this.

I have 3 instruments at the same time, and I want to choose between all you have available. The way I do this is:

3 input select

    document.querySelector("#instrumento-melody").addEventListener("input", function(){
        melodyInstrument = InstrumentChange(this.value)
    }, false);

    document.querySelector("#instrumentoPrincipal").addEventListener("input", function(){
        mainMetronomInstrument = InstrumentChange(this.value)
    }, false);
    document.querySelector("#instrumentoSecundario").addEventListener("input", function(){
        secundaryMetronomInstrument = InstrumentChange(this.value)
    }, false);

I load all the instruments:

    let instrumento = [];
    let mainMetronomInstrument = null;
    let secundaryMetronomInstrument = null;
    let melodyInstrument = null;
    player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0000_FluidR3_GM_sf2_file.js", "_tone_0000_FluidR3_GM_sf2_file");
    player.loader.waitLoad(function () {
	instrumento[0] = window["_tone_0000_FluidR3_GM_sf2_file"];
    player.loader.decodeAfterLoading(audioCtx, '_tone_0000_FluidR3_GM_sf2_file');
    mainMetronomInstrument = instrumento[0];
    secundaryMetronomInstrument = instrumento[0]
    melodyInstrument = instrumento[0];
    });

    player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0010_FluidR3_GM_sf2_file.js", "_tone_0010_FluidR3_GM_sf2_file");
    player.loader.waitLoad(function () {
	instrumento[1] = window["_tone_0010_FluidR3_GM_sf2_file"];});
                
                    
    player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0020_FluidR3_GM_sf2_file.js", "_tone_0020_FluidR3_GM_sf2_file");
    player.loader.waitLoad(function () {
	instrumento[2] = window["_tone_0020_FluidR3_GM_sf2_file"];});

                                   
    player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0030_FluidR3_GM_sf2_file.js", "_tone_0030_FluidR3_GM_sf2_file");
    player.loader.waitLoad(function () {
	instrumento[3] = window["_tone_0030_FluidR3_GM_sf2_file"];});
            .
            .
            .
          [...]

And a switch case:

    function InstrumentChange(instrument){
        console.log('cambiando');
        switch(instrument) {
            case "Acoustic Grand Piano":
                return instrumento[0];
            case "Bright Acoustic Piano":  
                return instrumento[1];                  
            case "Electric Grand Piano": 
                return instrumento[2];   
            case "Honky-tonk Piano": 
                return instrumento[3];
            case "Electric Piano 1":  
                return instrumento[4];                  
            case "Electric Piano 2":
      .
      .
      .
     [...]

Doing so works, the problem is that loading 100 instruments when page open is quite slow, I would like to load them only when they are required:

            case "Clarinet":        
                player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0710_FluidR3_GM_sf2_file.js", "_tone_0710_FluidR3_GM_sf2_file");
                player.loader.waitLoad(function () {
                instrumento[15]= window["_tone_0710_FluidR3_GM_sf2_file"];});
                return instrumento[15];
                break;

This returns me random empty buffer.

            case "Flute":
                player.loader.startLoad(audioCtx, "https://surikov.github.io/webaudiofontdata/sound/0730_FluidR3_GM_sf2_file.js", "_tone_0730_FluidR3_GM_sf2_file");
                player.loader.waitLoad(function () {
                return window["_tone_0730_FluidR3_GM_sf2_file"];});
                break;

And this doesn't work.

Am I doing something wrong?

Thank you

Glitch sound when using queueWaveTable

Hi, I am using webaudiofont to build a midi player. However, when I used queueWaveTable to play notes, it contained some glitch sound. I tried the example midi player here which does not give any glitch sounds. I wonder if there are any 'tricks' to eliminate them.

Android Firefox 68.0 does not support encoding for webaudiofont

Firefox 68.0 on Android phone will no longer play webaudiofont midi files. Even your simple sample https://surikov.github.io/webaudiofont/examples/simple.html# throws the following error. It is this error for my site as well.

The buffer passed to decodeAudioData contains invalid content which cannot be decoded successfully.
EncodingError: The given encoding is not supported.

I don't think it matters which tone file is loaded as your sample loads a different one from my site. Android Chrome works fine and so do desktop (PC) Chrome and Firefox. It is only Android 68.0 Firefox that is throwing this error - as well as Android FF Beta, and Developer's Nightly. So it seems like new mobile Firefox will be incompatible with something in your code base.

Do you have any insight into what could be tweaked to get this working again?

Ill timber/volume in specific tone range

Abstract

Suddenly, at first attempt, I came across weird sound in one specific interval, only within one specific semitone corresponding to MIDI notes 50 to 51. So far, I could not reproduce the problem in any other tonal range.

Steps to Reproduce

Run this and try microtonal sounds between MIDI notes 50 to 51, compare with other sounds:

<html>
	<head>
		<script src='https://surikov.github.io/webaudiofont/npm/dist/WebAudioFontPlayer.js'></script>
		<script src='https://surikov.github.io/webaudiofontdata/sound/0001_GeneralUserGS_sf2_file.js'></script>
		<script>
			var selectedPreset=_tone_0001_GeneralUserGS_sf2_file;
			var AudioContextFunc = window.AudioContext || window.webkitAudioContext;
			var audioContext = new AudioContextFunc();
			var player=new WebAudioFontPlayer();
			player.adjustPreset(audioContext,selectedPreset);
			function play(pitch) {
				player.queueWaveTable(
					audioContext, audioContext.destination, selectedPreset,
					audioContext.currentTime, pitch,
					0.4);
			} // play
		</script>
	</head>
	<body>

		<a href='javascript:play(2.0+12*4);'>MIDI note 50: E</a><br/>
		Moving up by 10 cents:</br>
		<a href='javascript:play(2.1+12*4);'>50.1</a><br/>
		<a href='javascript:play(2.2+12*4);'>50.2</a><br/>
		<a href='javascript:play(2.3+12*4);'>50.3</a><br/>
		<a href='javascript:play(2.4+12*4);'>50.4</a><br/>
		<a href='javascript:play(2.5+12*4);'>50.5</a><br/>
		<a href='javascript:play(2.6+12*4);'>50.6</a><br/>
		<a href='javascript:play(2.7+12*4);'>50.7</a><br/>
		<a href='javascript:play(2.8+12*4);'>50.8</a><br/>
		<a href='javascript:play(2.9+12*4);'>50.9</a><br/>
		Compare the sound!</br>		
		<a href='javascript:play(3.0+12*4);'>MIDI note 51: ♯F</a><br/><br/>
		But beyond the ill range shown above (between 50 and 51), everything is fine:</br>
		<a href='javascript:play(3.1+12*4);'>51.1</a><br/>
		<a href='javascript:play(3.2+12*4);'>51.2</a><br/>
		<a href='javascript:play(3.3+12*4);'>51.3</a><br/>
		<a href='javascript:play(3.4+12*4);'>51.4</a><br/>
		<a href='javascript:play(3.5+12*4);'>51.5</a><br/>
		<a href='javascript:play(3.6+12*4);'>51.6</a><br/>
		<a href='javascript:play(3.7+12*4);'>51.7</a><br/>
		<a href='javascript:play(3.8+12*4);'>51.8</a><br/>
		<a href='javascript:play(3.9+12*4);'>51.9</a><br/>
		Done!</br>		
		
	</body>
</html>

The Problem Background

I do understand that this work is not intended for microtonal use. But! As I can see, microtonal sound works even without any change in the library. Also, I seriously think that the main value of this library is its microtonal potential.

Presently, there is a great activity in music around microtonal field: development of novel instruments and tone systems, and so on. There is a lot of 12-tone software these days, but the microtonal capabilities present a considerable problem. It's much better to concentrate on support of microtonal systems now.

My Questions

  • Can you explain it?
  • Can you suggest some other way of using the microtonal tones?
  • Would you consider further development to offer microtonal versions of the API? If you can consider it, I can provide some help, as the very interested person qualified in the field. Alternatively, I could fork it and publish the fork if you don't mind and if you can support me with just answering some questions. In turn, I can explain what I would like to achieve.

Thank you.
—SA

How do I pause the Midi Demo?

I'm trying to use the Midi demo and would like to add a [Pause] button.

I have added a
var isPaused = false
and used it in the startPlay() function for the two setInterval().

Example:

setInterval(function () {
  if ((!isPaused) && (audioContext.currentTime > nextStepTime - stepDuration)) {code}

But this is not the complete solution, because when un-pausing it again, it starts going very fast to make up for the lost time.
This is because audioContext.currentTime is not paused I think.

Can you please help me in pausing it properly?
Thanks!
René

I would like to load and play four midi simultaneously.

I have found a way to do it in riffshare, by changing the file loader function, but I cannot find a way to load four midi files in webaudiofont and then play them simultaneously with gain nodes to alter their respective volumes. Do you have an example of loading from multiple simultaneous midi files? Thanks.

is it possible to play more than one note at the same time?

Hi there,

Is it possible to play more than one note at the same exact time? Like in a chord? It doesn't seem to work? Is this not possible using Audio Context? Do you need a new AudioContext in order to do this?

If it is possible, please provide a code example that demonstrates how to do this.

Thanks.

how to generate custom instrument file?

How to generate custom instrument file with all parameters(originalPitch, keyRangeLow, keyRangeHigh, loopStart, loopEnd, coarseTune, fineTune, sampleRate, ahdsr, sample) and all 88 notes for each zone?

Add tonejs support

I have been searching Tonejs implement for this project, only find a year ago you have been trying to implement here Tonejs/Tone.js#290 , wondering is there any progress?

Thank you for your awesome work!

[Question] Can I use your example/MIDIFile.js for midi loading in my project ?

I previously use tone.js for music play and tonjs/MIDIConvert for MIDI loading.

But it seems that there some differences between WebAudioFont and tone.js, and it seems that, your example/MIDIFile.js is more convenient whe =n using WebAudioFont.

But it seems that, MIDIFile.js is only for example purpose.
So, can I use it, and is it also under MIT license ?

Clicking

I've noticed clicking between notes when playing fast passages, especially with certain soundfonts like some of the flute sounds. Are there settings that can help to reduce clicking?

Sample using ES6/React?

I'm able to import WebAudioFont, but I can't figure out how to reference the WebAudioFontData in an ES6/React component. Any sample, help, or pointers would be appreciated.

thanks,

shane

0250_Acoustic_Guitar_sf2_file is flat

The font in 0250_Acoustic_Guitar_sf2_file is out of tune with all other songs. Compare, for instance, the E4 in https://surikov.github.io/webaudiofontdata/sound/0250_Acoustic_Guitar_sf2_file.html and in https://surikov.github.io/webaudiofontdata/sound/0250_Aspirin_sf2_file.html or https://surikov.github.io/webaudiofontdata/sound/0250_Chaos_sf2_file.html — the former is about one note lower than the others.

And unfortunately, WebAudioFontLoader.findInstrument will find exactly this font when Acoustic Steel Guitar is requested, so any MIDI songs with Acoustic Steel Guitar sound very wrong.

Transport

Tone.js features a Transport object that controls a “playback head” for triggering pre-scheduled single events (e.g. triggering a note to play). The object features functions such as play, pause, rewind. My question: does WebAudio Font feature an equivalent Transport facility? If so, please can you give me an introduction to using it or point me in the direction of documentation for its use. Many thanks, and congratulations on such a great product.

Converting to webaudiofont from another library

Hi, i am using midi-js and want to convert it to webaudiofont...
is there easy way to immigrate? Midi-js has chords like this { "C:maj": [ 60, 64, 67 ], "C:min": [ 60, 63, 67 ], "C:dim": [ 60, 63, 66 ], "C:maj7": [ 60, 64, 67, 71 ], "C:min7": [ 60, 63, 67, 70 ]
while webaudiofont has
var fretsAm = [-1, 0, 2, 2, 1, 0];
var fretsC = [-1, 3, 2, 0, 1, 0];
var fretsE = [ 0, 2, 2, 1, 0, 0];
var fretsG = [ 3, 2, 0, 0, 0, 3];
var fretsDm = [-1,-1, 0, 2, 3, 1];

Thanks

How to change playing speed, include pause and loop ?

I would like to use MIDI player for our small chorale. The main idea is to give possibilities to do repetitions and learning at home for all people. That is why I need to add some modifications to midi player as speed adjustment to sing some parts very slowly. Thanks for your help.

Add a ready boolean variable to the player

I'm looking for a way to disable the interaction while loading a soundfont until the loading and decoding is finished.

I looked at the dynamic loading example, and tried to implement the change function with no success.I thought the player.loader.waitLoad() was to be used as a callback but I can't seem to make it work. I also looked at the player.loader.progress() function but it always returns 1. I guess those are used when you download from the webfontaudiodata repo.

Is there a flag / variable / function that I can use to know when the player is ready to play ?

queueWaveTable with offset

Is it possible to play a portion of a waveTable?

Using envelop.audioBufferSourceNode.stop(T) I can (ugly) trim it from 0 to T, where 0 < T < duration.
What I should do to play just from T to duration? I need the sound "tail".
Something like the 2nd parameter of AudioBufferSourceNode.start.

Any tips to reduce latency?

Hi. First - fantastic project, thank you!

I am experimenting with a music player app that accepts keyboard/midi input and I have noticed there is some noticable lag between the keypress and the sound start. Maybe 100ms? It might vary from one PC to another.

At first I thought it might be the midi input but it also happens when using computer keyboard inupt.

I recall tricks in the past involving playing a silent note in the background so the audio system is already running when you play notes rather than turning it on/off frequently. Any thoughts on reducing latency?

static utilities

There are multiple functions that can be implemented as static functions like findInstrument, instrumentNames etc. There are many more like this. currently, I have to create an instance every time I have to use those utilities anywhere in the app.

Examples not working on Firefox or Edge on Win10 desktop

Issue: No sound plays on Firefox or Edge on Win10 desktop from examples or my own project.

Example: Go to https://surikov.github.io/webaudiofont/examples/simple.html# in Firefox 64.0.
Console log gives:
WebAudioFont Player v2.80 WebAudioFontPlayer.js:432:1
WebAudioFont Loader v1.27 WebAudioFontPlayer.js:45:1
WebAudioFont Channel v1.04 WebAudioFontPlayer.js:3:1
WebAudioFont Reverberator v1.08 WebAudioFontPlayer.js:745:1
load _tone_0000_JCLive_sf2_file 0000_JCLive_sf2_file.js:1:1
An unknown error occurred while processing decodeAudioData.
simple.html
EncodingError: The given encoding is not supported.
An unknown error occurred while processing decodeAudioData. simple.html
EncodingError: The given encoding is not supported.
empty buffer
Object { midi: 0, originalPitch: 5200, keyRangeLow: 51, keyRangeHigh: 55, loopStart: 87291, loopEnd: 87558, coarseTune: 0, fineTune: 0, sampleRate: 44100, ahdsr: true, … }

Known working: Desktop Win 10 Chrome, Vivaldi also Android chrome, Android Firefox

Thanks for putting webaudiofont out, it's been a great fit for stopping my current project get too bloated with audio files. Let me know if you need any further details.

about custom sample

Hello, I have followed the tutorial about custom sample and make a sound sample file. But it's very hard to do that. What's more, the sample I made has a great difference with my audio source.

Are there some auto-tools for making custom sample js file? I can't imagine that all instruments in the catalog are made by hand.

my email adress is [email protected]

hope your reply.

Using custom sound fonts

Hey! Amazing project! I was wondering how can I use this library with custom sound fonts. I see where I can add raw data? But I’m not sure what that means and how I would convert a sound font or wave to raw data

Possible to cancel a single sound via an event vs. audioContext in total?

Leveraging this library to create a text keyboard based instrument and I'm wondering if it's possible to cancel a queued up / currently playing sound via say a 'keyup' or some other event? I see that we can predetermine the overall length of the sound via the duration argument at the time of calling queueWaveTable and I've played around with the cancelQueue function on the player by passing it the audioContext. This worked, but canceled all of my currently playing notes. Is there some way I can target a specific sound that has been queued?

Oh and thanks for this! Having so much damn fun over here! 👍

Audio crackly on iOS 9 Safari.

Hi, I'm looking at options for a midi player for a game we are developing. Unfortunately we need to support iOS 9 on iPad 2.

I've managed to get the midiplayer.html example working by making some small tweaks to MIDIFile.js, I've replaced let & const references with var, however while playback does seem to work it's a bit crackly. The sample rate seems fine at 44100 Hz. Any ideas what may be causing it? The library suits our needs almost exactly just this crackly noise problem.

Better explanation of AFTER_TIME

Srgy,

We have made contact before at the old BabylonJS forum. I have been integrating this repo with an animation system of mine. I have done a lot of breaking of things into classes, using Typescript. The reason I have done so, in addition to understanding the code, is so that I could make a sub-class of Preset, which I call VoiceFont. I have also added a method to Player, to queue zones of this preset type.

This class has an additional property in each of its zone's, phoneme. The class also has additional methods for creating / testing / trimming of zones, as well as saving of the "instrument". None of which this repo has needed to do.

I was making the buffer of vowel zones, about 2 seconds & ahdsr = true. The consonant zones, I was making "to size", which is very small, 0.04 to 0.08 seconds. This is about the size of AFTER_TIME itself.

Which brings me to, what is AFTER_TIME? If this were set to zero, would a series notes of real instruments just run together? If so, I could probably add an additional property to zones with the default value of 0.05, and explicitly set those in VoiceFont to 0. I do not want any gaps for my "instruments".

This is almost starting to run, but the consonant "notes" seem really short to almost not sounding.

FYI, I have also integrated Carnegie Mellon University's ARPABET 10k word phonetic database. I can just type in what I want & syllables are generated. For a look at very old version of my animation system, see & click Talk. Back then I was using sound files & trying to voice sync.

And yes, I plan to sing if possible, so should I be adding 0.05 gaps between my syllables to keep in sync with the real instruments?

Thanks,

Jeff

Unable to play sounds on iOS

Describe the bug
I'm using webaudiofont on my website to generate audio as a "pitch pipe". When a user presses the "pitch pipe" button, it plays four notes consecutively: The first note of the bass, tenor, alto, and soprano parts of a song. This works on Safari, Chrome, and Firefox on macOS, but doesn't work on Safari on iOS.

To Reproduce
Steps to reproduce the behavior:

  1. On an iOS device, go to a page with a pitch pipe button: https://singpraises.net/collections/en/hymns/the-morning-breaks/presentation-lyrics?audiotype=pp
  2. Tap where it says "Pitch pipe ▶".

Expected behavior
Audio should play four consecutive notes.

Smartphone (please complete the following information):

  • Device: iPhone 11 Pro
  • OS: iOS 13.3
  • Browser: Safari
  • Version: (13.3)

Additional context
This is my first time using webaudiofont, so it's possible I'm doing something wrong – however, my setup is simple and it seems to work on other platforms (just not on iOS).

The pitch pipe button has an onclick attribute, which calls playPitchPipe(['C3', 'C4', 'E4', 'G4']);:

<button id="options-button" class="icon-button" onclick="playPitchPipe(['C3', 'C4', 'E4', 'G4']);">Pitch pipe <i class="fa fa-play-circle"></i></button>

I'm loading webaudiofont and a sound font like this:

      <script src="https://surikov.github.io/webaudiofont/npm/dist/WebAudioFontPlayer.js"></script>
      <script src="https://surikov.github.io/webaudiofontdata/sound/0000_Chaos_sf2_file.js"></script>

And this is my JavaScript:

      var AudioContextFunc = window.AudioContext || window.webkitAudioContext;
      var audioContext = new AudioContextFunc();
      var player = new WebAudioFontPlayer();
      player.loader.decodeAfterLoading(audioContext, '_tone_0000_Chaos_sf2_file');
      function playPitchPipe(pitches) {
        for (var p = 0; p < pitches.length; p++) {
          player.queueWaveTable(audioContext, audioContext.destination, _tone_0000_Chaos_sf2_file, audioContext.currentTime + (0.75 * p), convertToMidi(pitches[p]), 2);
        }
      }

in function player.findEnvelope, envelope.when and envelope.duration is always undefined if it is newly created.

if (!(envelope)) {
envelope = audioContext.createGain();
envelope.target = target;
envelope.connect(target);
envelope.cancel = function () {
if (envelope.when + envelope.duration > audioContext.currentTime) {
envelope.gain.cancelScheduledValues(0);
envelope.gain.setTargetAtTime(0.00001, audioContext.currentTime, 0.1);
envelope.when = audioContext.currentTime + 0.00001;
envelope.duration = 0;
}
};
this.envelopes.push(envelope);
}

suggested fix:

envelope = audioContext.createGain();
envelope.target = target;
envelope.when = when;
envelope.duration = duration;
envelope.connect(target);

Empty buffer object

I´m trying to use your webaudiofont in my AddMIDIweb app. I select only a few instruments to sound. But when I start the page the buffer of instrument is empty and I have to click twice the play buttom to load an instrument for the first time. There is something wrong with my code but what is it? Can you help me? Thanks for your time.

add note on - note off to API

To enable live performance (via Web Midi), library has to provide API for realtime playing, which essentially boils down to implementing note on - note off (with specified velocity). Adding sustain pedal on-off would be perfect (though it's easy to add on application level).

How do you change the volume of a Tone.WebAudioFontInstrument node?

Hi I'm using this code

synth = new Tone.WebAudioFontInstrument({
  			"oscillator" : {
  				"type" : "sine"
  			},
  			"envelope" : {
  				"attack" : 0.01,
  				"decay" : 0.2,
  				"sustain" : 0.2,
  				"release" : 0.2,
  			}
  		}).toMaster();

and I can't figure out how to change the volume. I've tried everything on the tone js website and nothing works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.