New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorten recording length after recording has completed #105
Comments
Managed to make this work by doing the following: recorderWorker.js
Frame/time accurate recordings!! woop |
I raised an issue very similar to this last week. I had some sample code that did manual processing of the WAV file. I actually think RecorderJS should not include this functionality as it seems to sort of pollute the basic idea of what the lib actually does. I do however wish the export wav function was a little more generic. I had to process the header on my own which required a lot of know-how, and I didn't want to pollute my local copy of the lib by chopping and extending the functionality, especially since this lib uses web workers which, IMO, are not exactly production safe. Rather, I think an editing tool built on top of this lib makes more sense and should maybe be included with Recorder or as a linked project to Recorder. You are most likely going to want to customize the processing of these files. However, having the worker do that manipulation seems somewhat unsafe and not really in the spirit of how this tool is built. |
And by editing tools -- things such as downsampling, chopping, concatenating, etc. etc. |
I would imagine it's more efficient for the Worker to chop the length of the array before it does any further processing. Also because it already has a loop which creates the buffers, it could save processing time from the start. An editing library on top of Recorder.js would be great for more advanced functions, maybe there could be a beforeProcessing function hook which allows you to modify the raw recording data before Recording.js continues processing |
You're right, it is probably more efficient. Sort of a balance though, since thread safety with web workers is definitely a question. IMO, if the workers were more stable then I'd agree. For now, I'd try to avoid interacting/using the worker as much as possible since I think there are serious questions regarding the stability/safety of them. Maybe I'm overly paranoid? I might be interested in putting together a library of editing tools. Similarly, I think there needs to be some kind of playback state machine as well, which I am already working on as part of my job. I'll see what I can do about open-sourcing some of those things. |
Yeah agreed! playback would be awesome. I have had to write it all from scratch which has been long and frustrating. I needed the ability to playback backing and vocal loops, in SYNC! which is massively complex. Also things like webkit audio is muted until a touch start interaction!! I think I have it achieved it with this (feel free to reuse this code for your open source library):
|
Have a look at Howler which is an OSS js library for exactly dealing with multiple playbacks. |
I'll see if I can scratch together a player state machine in the next few days and get back to you. Nice work btw. |
Thanks, it's not perfect but seems to work. Here is my list of requirements for a Recorder.js toolkit: General
Record
Play
Stop
|
Sounds like this would be like some kind of loop pedal? |
Yeah that's basically what i'm making. Even better would be if you could change the timing after the recording. Because it's so hard to get the offset, latency correct. If you could record it, then adjust the offset afterwards in time to the other loop. Then when you hit export, it would chop the wav to match that offset and at the correct length. I was going to try make it myself, but it made my head hurt :) At the moment they have to set their latency offset before recording (which is -150ms means nothing to them!) then after the recording if the offset is wrong, they have to discard and re-record it again. Such a bad user experience! |
https://github.com/goldfire/howler.js/ Look into that, it might be helpful. I don't know how much, but it's a starting point. The other problem with in-time recording/looping is tricky and the latency issues will be problematic. When you're cutting audio, you need to make sure you are padding the wav file with an extra byte if the payload is odd. |
@b-d-b I've put together the requirements I think will create a better user experience for recording here: Next step is to actually start writing the code! |
Using this example I was able to find out how to insert blank space into the recording: I've now managed to almost replicate the functionality I need, however the white noise seems off. Is there a miscalculation somewhere? |
@b-d-b I managed to solve this filling in the blank space at the start and end of the recording with silence, so the recording length always matches the original loop length (or a multiple of that loop length). this means when they are played together they are always looped in time! Here's the logic for working out the blank spaces at the start and end:
and in javascript code it looks like this:
I made a full working example here: |
Hello kmturley, how did you get this feature can you help?? |
@sanaali110 thanks! this.context = new window.AudioContext(); and data is the decoded audio data which is loaded via an ajax request |
thanks alot.. really appreciate |
I am using this awesome library to record loops on my site. To do this I have to overcome two big problems.
Latency, due to the buffer/hardware latency I have to allow the user to offset the recording time so it starts at the same time no matter which device/browser you are on. Would be great to build this offset functionality into Recorder.js
Recording length, due to the buffer length and the sample rate, the recording either stops before or after 3 seconds. Never exactly on 3 seconds. This is because the buffer doesn't divide exactly into the sample rate. The solution to this is suggest to my question here:
http://stackoverflow.com/questions/28424111/recorder-js-calculate-and-offset-recording-for-latency/
I have created an example page where the sound is recorded longer then needed, and then chopped back to fit the desired length. What i'm wondering is whether we can add this functionality into Recorder.js also? Here is my version:
http://kmturley.github.io/Recorderjs/
My suggestion would be to allow you to set the recording length after the recording has occurred:
However this throws errors when you start exporting wavs or buffers :(
The text was updated successfully, but these errors were encountered: