added sampling rate input to "new sound" primitive

pull/89/head
jmoenig 2019-10-20 14:07:55 +02:00
rodzic 6306bcc279
commit 371769ae40
3 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -15,6 +15,7 @@
### 2019-10-20
* objects, threads: added "new sound" from list of samples primitive reporter to "sound" category
* objects, threads: added sampling rate input to "new sound" primitive
### 2019-10-18
* objects, blocks, threads: added dimension getters for the stage

Wyświetl plik

@ -481,7 +481,8 @@ SpriteMorph.prototype.initBlocks = function () {
reportNewSoundFromSamples: {
type: 'reporter',
category: 'sound',
spec: 'new sound %l'
spec: 'new sound %l at %rate Hz',
defaults: [null, 44100]
},
doRest: {
type: 'command',

Wyświetl plik

@ -2818,7 +2818,7 @@ Process.prototype.encodeSound = function (samples, rate) {
// Process first-class sound creation from samples, interpolated
Process.prototype.reportNewSoundFromSamples = function (samples) {
Process.prototype.reportNewSoundFromSamples = function (samples, rate) {
// interpolated
var audio, blob, reader,
myself = this;
@ -2829,7 +2829,7 @@ Process.prototype.reportNewSoundFromSamples = function (samples) {
};
audio = new Audio();
blob = this.audioBufferToWaveBlob(
this.encodeSound(samples, 44100).audioBuffer,
this.encodeSound(samples, rate || 44100).audioBuffer,
samples.length()
);
reader = new FileReader();