accept a number as input for a sound - interpret as index

pull/89/head
jmoenig 2019-04-08 16:04:49 +02:00
rodzic d1df74c7fc
commit 5427a7a396
3 zmienionych plików z 21 dodań i 10 usunięć

Wyświetl plik

@ -50,6 +50,7 @@
* using "inherit" no longer un-hides the palette in presentation mode
* relabelling custom blocks with empty numerical input slots no longer fills in zeroes
* the language menu now has a "globe" icon (so it can be found in any language)
* accept a number as input for a sound - interpret as index
* Translation Updates:
* Chinese, thanks, Simon!
* Turkish, thanks, Turgut!
@ -63,6 +64,7 @@
* Blocks, Objects, Threads: new "getSoundAttribute" reporter primitive
* Blocks, Objects, Threads: new "play sound at sample rate" command primitive
* Objects: added relabelling information for the new "play sound at sample rate" block
* Objects, Threads: accept a number as input for a sound - interpret as index
### 2019-04-05
* Objects: eliminated "clicks" when playing music notes

Wyświetl plik

@ -3323,10 +3323,12 @@ SpriteMorph.prototype.addSound = function (audio, name) {
SpriteMorph.prototype.playSound = function (name) {
var stage = this.parentThatIsA(StageMorph),
sound = name instanceof Sound ? name : detect(
this.sounds.asArray(),
function (s) {return s.name === name.toString(); }
),
sound = name instanceof Sound ? name
: (typeof name === 'number' ? this.sounds.at(name)
: detect(
this.sounds.asArray(),
function (s) {return s.name === name.toString(); }
)),
ctx = this.audioContext(),
gain = this.getGainNode(),
pan = this.getPannerNode(),

Wyświetl plik

@ -2254,9 +2254,12 @@ Process.prototype.doPlaySoundAtRate = function (name, rate) {
i, source, rcvr;
if (!(name instanceof List)) {
sound = name instanceof Sound ? name : detect(
this.blockReceiver().sounds.asArray(),
function (s) {return s.name === name.toString(); }
sound = name instanceof Sound ? name
: (typeof name === 'number' ? this.blockReceiver().sounds.at(name)
: detect(
this.blockReceiver().sounds.asArray(),
function (s) {return s.name === name.toString(); }
)
);
if (!sound.audioBuffer) {
this.decodeSound(sound);
@ -2315,9 +2318,13 @@ Process.prototype.doPlaySoundAtRate = function (name, rate) {
};
Process.prototype.reportGetSoundAttribute = function (choice, soundName) {
var sound = soundName instanceof Sound ? soundName : detect(
this.blockReceiver().sounds.asArray(),
function (s) {return s.name === soundName.toString(); }
var sound = soundName instanceof Sound ? soundName
: (typeof soundName === 'number' ?
this.blockReceiver().sounds.at(soundName)
: detect(
this.blockReceiver().sounds.asArray(),
function (s) {return s.name === soundName.toString(); }
)
),
option = this.inputOption(choice);