fenomas / wafxr

sound effects for the web
https://fenomas.github.io/wafxr/
59 stars 2 forks source link

Any chance of getting an 'export to .wav' function? #1

Closed NeuroNoNeuro closed 3 years ago

NeuroNoNeuro commented 3 years ago

This particular SFX generator leaves the rest in the dust! PLEASE may we have a version that can export the audio. I use Renoise professionally here: http://www.audiobulb.com/albums/AB099/AB099.htm and would love to have the capability to use the sounds that this generator can create for various melodic and percussive waveforms.

Playing with it, it's a dream synth. I'm a synth geek, and make all my own sounds. PLEASE!?!?!? :D

fenomas commented 3 years ago

Hey thanks! I have thought about this and I think it wouldn't be so hard to implement, but I haven't tried it yet. I will comment here if I get it working.

Now I'm vibing to the album you linked. Really nice stuff!

fenomas commented 3 years ago

Hey, I took a stab at this and it seems to work on my machine (tm). Can you try it out?

NeuroNoNeuro commented 3 years ago

Will do!

NeuroNoNeuro commented 3 years ago

Works great! I do notice it does tend to start the sample playback at 2,500 samples in. Not a real issue, I'm probably going to go in and edit the sample anyway.

Screen Shot 2020-10-26 at 3 06 56 AM

P.S. I'm glad you enjoyed the Audiobulb label link! There's a TON of great music on that label, it's been running since 2003.

fenomas commented 3 years ago

Ah right, there's a delay there to avoid clicks in realtime, it would be easy to change.

What would you expect here, a smaller delay, or the signal to begin right from the first sample?

NeuroNoNeuro commented 3 years ago

If exporting audio, then the signal starting from the first sample would be ideal. Less choppin'! I'm just happy to have a sound generator of this magnitude. I use JSFXR/SFXR/BFXR from time to time, but this makes a greater range of sound(s). I used to use a Windows program, back in '99/'00 called Orangator, and this has that sort of capability - to grow greater sounds with more modulation possibilities.

NeuroNoNeuro commented 3 years ago

One other small request - while a user gets automatic updates to hear a sound upon slider movement, if the space bar could also be used as a trigger for more in-depth listening to a sound - basically to repeat playback to be assured of the sound. Just because SFX (which I also do for many games) require that sort of finesse.

fenomas commented 3 years ago

Hi, I'm putting in the change to remove the intro delay.

While you're here, in the standard demo the audio runs through a compressor (with default values for webaudio), both when used interactively and when exporting. For your use case, is that good or is it better without?

As for the space bar, it should already be doing exactly what you say - A~Z key inputs should play the current sound at various frequencies, and spacebar should play whatever the most recent frequency was. (if the cursor is in a textfield this doesn't happen though.) If keys never play sounds, please let me know your browser, any errors in the JS console, etc!

NeuroNoNeuro commented 3 years ago

Oh neat! The compressor is good - better safe than sorry, and anybody can edit the audio later on. Space bar and keyboard - I wish I had tried it before I asked... SO COOL!!! Works great and is very handy. Man alive, put this up on itch.io for a buck or two. Also, this turns out some beautiful waveforms for single-cycle synthesis.

NeuroNoNeuro commented 3 years ago

Jumping Jesus on a pogo stick, it makes cymbals.

NeuroNoNeuro commented 3 years ago

I would say, the only other thing that would benefit this, and it can already be done, is being able to have the capability of saving these as a preset via a "Save" button. I can copy/paste just fine, though. Maybe a future edit? Right now, this bit of code won't reload the sound of a bass drum in a page reload, and I cannot seem to export the actual sound. Just this sound so far.

// import Gen from 'wasgen' // var gen = new Gen() gen.play([ {type:"n1", freq:[{w:0.01,t:2,f:200,a:0,p:10,q:0.01,x:1},{w:0.01,t:2,f:200,a:0,p:10,q:0.01,x:1},{type:"sine", freq:{t:1,f:0}, gain:{t:1,a:0.1,d:0.1,s:0.8,r:0.1}}], gain:{a:0,h:0,d:0,s:0,r:0.04},effect:"shape-boost-20"}, {type:"bandpass", freq:{t:0.1,p:0.1,q:0.01},Q:10}, {type:"lowpass", freq:{t:0.4,p:0.1,q:0.01},Q:10}, ], 3273, 1, gen.now(), gen.now() + 0.004)

I can copy paste it, but have no way of making the synth play it back (that is apparent). It actually switches the code back to the original 'reset' sound.

So, this sound (in one tab) plays back, but does not export, gives me a blank .wav file, and in the other tab, I can copy/paste it, but it will not 'load' the sound to be played back.

fenomas commented 3 years ago

Yes I follow you, the low-hanging fruit for a next feature if I get time would be some kind of history for the editing flow, like sfxr etc. Right now there's no way to get back any set of settings you had previously. But this might take more than an evening though so no promises 😀

For me, the flow is that I use the GUI for ideation and then any fine-tuning I do on the text representation (which is in an ad-hoc format for wasgen, the underlying dependency that actually plays the sounds). But that's not really useful for your use case since you're exporting WAVs to use elsewhere.

Glad you're liking it, I will push a change later on to remove the intro delay. (most of it that anyway, the compressor seems to impose a certain amount.) Please do file more issues for anything else that comes to mind!

NeuroNoNeuro commented 3 years ago

You asked for it, you got it. Toyota! 🙂

NeuroNoNeuro commented 3 years ago

Yes I follow you, the low-hanging fruit for a next feature if I get time would be some kind of history for the editing flow, like sfxr etc. Right now there's no way to get back any set of settings you had previously. But this might take more than an evening though so no promises 😀

For me, the flow is that I use the GUI for ideation and then any fine-tuning I do on the text representation (which is in an ad-hoc format for wasgen, the underlying dependency that actually plays the sounds). But that's not really useful for your use case since you're exporting WAVs to use elsewhere.

Glad you're liking it, I will push a change later on to remove the intro delay. (most of it that anyway, the compressor seems to impose a certain amount.) Please do file more issues for anything else that comes to mind!

Saw that wasgen last night, and was reminded of my old computer's OPL2/3 synthesis. Beautiful sounds to be had there, some of my more preferred 2OP (4OP?) FM tones. First noticing that you were incorporating FM into the SFX generator is what piqued my interest in viewing your other audio projects. For sound generation, it's really an excellent avenue to explore - you've made it user-friendly. On top of that, you're also doing some various other forms of synthesis which can also be altered via FM - looks like harmonic(additive), and for the metallic timbres, who knows? This makes the SFXR (and it's older Flash sibling) less capable 👍

Tell me you're gonna turn this into a drum synthesizer... I bet. It already is, but if it has a starting point, like "coin" or "jump". Wowee mannn...

Once this gets just a little tighter, I want to share it on the Renoise forum(s), because it is very useful. Endless percussion, endless melodic tones. I mentioned the single-cycle generator idea; for some of the sounds, I'll be chopping out a single-cycle. If there was also (way in the future) a method for export a single-cycle, with adjustable length (Renoise uses a 168-sample 'cycle'...so weird), you'd be blowing the SCW and https://bgc.github.io/waveformgenerator/#/ sites out of the water. Because the synthesis methods are so broad here.

As a side-note, I've been requesting to the owner/programmer of Renoise to incorporate the FM techniques into the sampler (along with granular/phase distortion/wave-folding), as the sequencer is so good, there's very little left to work on besides sound-generation. Automatable LFOs that could go into the audio range? Why not? It's a matter of updating the already present LFO to have a greater frequency range. The sampler and effects are excellent, and could use a nudge in the direction of updating it's sound features, either sample manipulation or sample-synthesis. I stopped using VST/AUs once I got a hold of Renoise. That's how good it is.

Alright, I know it's getting late, yakkity yak over here.

NeuroNoNeuro commented 3 years ago

EDIT: AHA!!! It's the synth's "Duration" parameter, paired with the anti-click 2500 samples. The end-user just needs to keep the "Duration" between .5 and longer to get a decent length of sound, and once the anti-click parameter is adjusted, then this will be less of an issue.

I think I might have figured out why it won't export bass-drum sounds - they might be too quick, and falling inside the 2500 blank-sample export function. Maybe? Sample on the top is the bass drum (it's very short). Sample on the bottom is a "UI" sound.

Screen Shot 2020-10-26 at 7 24 36 AM

NeuroNoNeuro commented 3 years ago

Timing is improved! Much better and will offer quicker editing - thank you!

fenomas commented 3 years ago

Hi, thanks for looking at the drum sound thing. You're right, basically the code that decided the total export duration didn't know about the default delay being added to the beginning. I adjusted things so that the exported envelope starts immediately (probably 5-6 samples in, in practice), which should fix it.

Incidentally, while doing that I found a different subtle bug that messed up attack ramps for short drum-like sounds. Hopefully that's fixed now, but I just pushed it a few minutes ago.

The further info is very interesting, though I'm very new to audio synthesis so I didn't follow all of it. I'm not at all familiar with other audio tools, so this tool may be doing things differently than you'd expect in some random place.

Since I may be defining things differently than usual tools, here's a quick summary of how the timing sliders (should) work. Basically "duration" is how long the note is held during the "decay" phase of the ADSR envelope. That is, the attack and hold settings are the durations of those phases, then sustain is the sustain level that it decays down to, and duration is how long it spends decaying. Then the note "releases", and the release parameter is the time constant for how quickly it decays to silent. Hope that makes sense.

Regarding drum noises, yeah I totally use this (or rather wasgen underneath) for doing drums. If you open the wasgen demo and set the "effects" pulldown to "kick" or "hihat" you'll get some rough examples. (The kick sounds only sound like kicks if you play a low note, i.e. hit "z" or "x" on the keyboard.) You get the idea.

Again, let me know any other low hanging fruit I'm missing here! Please open separate issues for anything other than wav output, so I can track things.