Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40714
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Monkey gibberish |
| Date | 2021-12-23 12:15 +0000 |
| Organization | A little, after lunch |
| Message-ID | <sq1p8p$ho0$2@dont-email.me> (permalink) |
| References | (1 earlier) <e7883088-5cdb-4612-8440-9f326920c7b5n@googlegroups.com> <slrnss24oc.4j7.jon+usenet@raven.unequivocal.eu> <1b308090-25ac-4f8d-9f2b-efc88b80b407n@googlegroups.com> <f1b5dbea-94db-430d-8aa2-f7d26fadd0b7n@googlegroups.com> <d6b7e850-8ed0-4820-8ff9-23e0c667fcb8n@googlegroups.com> |
On 22/12/2021 20:53, Jonas Thörnvall wrote:
> onsdag 22 december 2021 kl. 21:33:03 UTC+1 skrev Jonas Thörnvall:
>> onsdag 22 december 2021 kl. 21:26:47 UTC+1 skrev Jonas Thörnvall:
>>> tisdag 21 december 2021 kl. 00:34:44 UTC+1 skrev Jon Ribbens:
>>>> On 2021-12-20, luserdroog <luser...@gmail.com> wrote:
>>>>> On Monday, December 20, 2021 at 3:19:41 PM UTC-6, jonas.t...@gmail.com wrote:
>>>>>> I have a bit hard to read monkey gibberish, is there a way to explain
>>>>>> this to someone who is not fullfledged retarded?
>>>>>>
>>>>>> .then(res => res.arrayBuffer())
>>>>>> .then(ArrayBuffer => ctx.decodeAudioData(ArrayBuffer));
>>>>>>
>>>>>> Specifically
>>>>>> .then =>
>>>>>> Is there another way to write it that may not be gibberish?
>>>>>
>>>>> I think this is the new fad called "monadic sequencing". If I'm right,
>>>>> the above can be translated into:
>>>>>
>>>>> var x = res.arrayBuffer(); //only it won't be called "res", but the name of the previous result
>>>>> var y = ctx.decodeAudioData(x);
>>>>>
>>>>> Or even:
>>>>>
>>>>> ctx.decodeAudioData( res.arrayBuffer() ); //again, "res" isn't the correct name here
>>>>>
>>>>> It's just a sequence of functions "arg=> expression" where the result
>>>>> of one is passed as the argument to the next. You can do the same
>>>>> thing with a series of temporary variables or by composing all the
>>>>> expressions into one massive expression.
>>>> The important bit you didn't mention is that it's dealing with Promises.
>>>> So you can't do either of the things you suggest above. If you're in an
>>>> async function you could do this however:
>>>>
>>>> const audioData = await ctx.decodeAudioData(await res.arrayBuffer())
>>> Why can't i do this.
>>> const audiostream = new AudioContext();
>>>
>>> async function audioPlay(url){
>>> const audioBuffer = await fetch(url)
>>> .then(res => res.arrayBuffer())
>>> .then(ArrayBuffer => audiostream.decodeAudioData(ArrayBuffer));
>>> const playwav = audiostream.createBufferSource();
>>> var gainNode = audiostream.createGain();
>>> gainNode.gain.value = -0.1;
>>> playwav.buffer = audioBuffer;
>>> playwav.connect(audiostream.destination);
>>> playwav.start();
>>> };
>>>
>>> or this to set volume
>>>
>>> const audiostream = new AudioContext();
>>> var gainNode = audiostream.createGain();
>>> gainNode.gain.value = -0.1;
>>>
>>> async function audioPlay(url){
>>> const audioBuffer = await fetch(url)
>>> .then(res => res.arrayBuffer())
>>> .then(ArrayBuffer => audiostream.decodeAudioData(ArrayBuffer));
>>> const playwav = audiostream.createBufferSource();
>>> playwav.buffer = audioBuffer;
>>> playwav.connect(audiostream.destination);
>>> playwav.start();
>>> };
>> I mean using .start() with an volume parameter, is what any none anal person would do.
> How many models do a programming language need, if you can write the code in a dousins of ways, it will be hard to read without a manual.
> Why did they not just do something like
> playwav.setVolume(-0.5);
>
> Why invent a hierarchy of idioties to write to set the volume?
>
Because Object Orientation Is Kewl and plebs like you dont understand it
so they get your job.
--
"In our post-modern world, climate science is not powerful because it is
true: it is true because it is powerful."
Lucas Bergkamp
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-20 13:19 -0800
Re: Monkey gibberish luserdroog <luser.droog@gmail.com> - 2021-12-20 15:00 -0800
Re: Monkey gibberish Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-12-20 23:34 +0000
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 12:26 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 12:32 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 12:53 -0800
Re: Monkey gibberish The Natural Philosopher <tnp@invalid.invalid> - 2021-12-23 12:15 +0000
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-21 13:41 +0100
Re: Monkey gibberish The Natural Philosopher <tnp@invalid.invalid> - 2021-12-21 15:40 +0000
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-22 10:30 +0100
Re: Monkey gibberish The Natural Philosopher <tnp@invalid.invalid> - 2021-12-22 12:05 +0000
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 10:00 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 10:21 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 10:26 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 12:24 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 15:06 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 15:08 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-21 15:08 -0800
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-22 10:33 +0100
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-22 10:31 +0100
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 03:34 -0800
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 03:41 -0800
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-22 17:12 +0100
Re: Monkey gibberish John Harris <niam@jghnorth.org.uk.invalid> - 2021-12-22 18:26 +0000
Re: Monkey gibberish Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-12-22 12:05 -0800
Re: Monkey gibberish Arno Welzel <usenet@arnowelzel.de> - 2021-12-23 02:37 +0100
csiph-web