Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Please use your imagination and try to imagine one of infinitely many other streams that I could make at runtime that are not easily made with the built-in toy oscillators.

Somebody already did. Check out Fourier Theory. The oscillators (well actually just sin, the rest will give you some help as well) can be used to make any stream, technically.



Unfortunately, you need an infinite number of them to construct any signal, and I think my computer would run out of memory before that :)


Use a square wave.


Ah yes, just run a square wave at twice the range of human hearing, then use a combination of filters to extract the desired ranges. Unfortunately you'd also need an infinite arrangement of filters.


You're making music. It's not that difficult.

http://kruhft.bandcamp.com/

Here's a synth using the technique:

http://busfactor1.ca/kruhft


I propose a challenge then. I'll give you an arbitrary stream in the format of a .wav, and you send me code, in JavaScript, that uses an series of infinite OscillatorNodes that reproduces that stream completely accurately.

I won't even make you write the code that generates the stream, I'll just require that one sample.

If you can do it, I'll give you $1000 out of my own pocket.


Wagers are the mother of all innovation, so I wholeheartedly support this.


If you're not sampling at an infinite sample rate, you don't need an infinite series of nodes.

Given Nyquist, a non-infinite series of [non-trivial power of 2] nodes will do the job just fine.

Audio FFT/iFFT processing typically uses 512 or 1024 bins, although sometimes you can get away with fewer.

In practice, iFFT doesn't use discrete oscillators for resynthesis, because the whole point of iFFTs is to limit the amount of work you have to do.

But there's no reason in theory a limited number of oscillators couldn't do the job. (I've done resynthesis like this in SuperCollider when I wanted special effects that FFTs can't produce.)

I doubt WA would be fast enough on most machines, but it would probably be possible - if rather dumb - on powerful hardware.


I'm well aware of discrete fourier transforms, and that we're dealing with a ~20KHz bandlimited signal. My original "infinite series" reply was a joke poking at the ridiculous idea of using iFFT for sample playback that seemed to get interpreted as a serious response by kruhft.


I was talking about synthesis, which is what the oscillators of web audio are for. I figured that was obvious.


Thank you.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: