Skip to content
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

Question: Download processed audio without playing track #86

Open
bragle opened this issue Jun 28, 2022 · 3 comments
Open

Question: Download processed audio without playing track #86

bragle opened this issue Jun 28, 2022 · 3 comments
Labels

Comments

@bragle
Copy link

bragle commented Jun 28, 2022

Sorry if this is a silly question, but I'm trying to download the output from an audio module after applying effects without having to play the whole track. With the recorder module, it seems like I'm only able to record while the track is playing. Is there any way to process the whole track and get a AudioBuffer or something like that with the effects applied?

Also, do have an estimate on when #18 will be implemented?

Super cool library you've made. Currently working on a new tool on devina.io. Would you like me to plug any of your socials etc when it's done?

@Korilakkuma
Copy link
Owner

Korilakkuma commented Jul 1, 2022

@bragle

Thank you for your nice question.

Sorry ... current version cannot record audio without playback.

XSound.app.mp4

Maybe, OfflineAudioContext makes it possible (I have this idea (#35), but not decide when to implement it ...).

Also, I do not decide when to implement #18.

Thanks !

@bragle
Copy link
Author

bragle commented Jul 1, 2022

Alrighty. I'm gonna try to implement OfflineAudioContext myself, then. If you wouldn't mind pinging me or just referencing this issue/question if you end up implementing either one of those, that would be sweet 😸

@eetsceeck1
Copy link

eetsceeck1 commented Sep 22, 2022

i did discovered this library today and its looks much awesome than tuna,
i have no idea how to connect it to audio context so i did open an issue,
anyway while scrolling on issues i saw your question i have no idea if i got it right what youre trying to achieve but i have a small code which i did merge from many other tiny codes to make it working what will record a sound from audio context with effects or without, anything comes from the source will be recorded maybe you will find it useful,

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<audio id="HTMLAudioElement" crossOrigin="anonymous" autoplay controls preload="none" src="track.mp3"></audio>
<script src="./recorder.js"></script>

<div id="controls">
    <button id="recordButton">Record</button>
    <button id="pauseButton" disabled>Pause</button>
    <button id="stopButton" disabled>Stop</button>
</div>
<h3>Recordings</h3>
<ol id="RecordingsList"></ol>

<script>
///	DEFINE HTML AUDIO ELEMENT SELECTOR.
let HTMLAudioElement = document.getElementById("HTMLAudioElement");

/// ***** NONE RELATED FUNCTION ***** 
	HTMLAudioElement.oncanplay = function(){

///	new audio context 
	var anAudioContextObject = new AudioContext();
	
///	SOURCE
	var SourceVariable = anAudioContextObject.createMediaElementSource(HTMLAudioElement);
	
///	================================> SIMILAR TO REVERBS (CREATE GAIN).
	var gainNode = anAudioContextObject.createGain();
	
///	CREATE CONNECTION TO WHATEVER THE OBJECT
	SourceVariable.connect(gainNode);
	

	gainNode.connect(anAudioContextObject.destination); 

///
///	===============================================================================================
	gainNode.gain.value = 0.5;

	var rec;
	rec = new Recorder(gainNode, {
        numChannels: 1
    }) 
	
	rec.record();
	setTimeout(function(){
	gainNode.gain.value = 0.5;
	}, 200);
	
	setTimeout(function(){
	rec.stop()
    rec.exportWAV(createDownloadLink);

function createDownloadLink(blob) {
    var url = URL.createObjectURL(blob);
    var li = document.createElement('li');
    var link = document.createElement('a');
    link.href = url;
    link.download = new Date().toISOString() + '.wav';
    link.innerHTML = link.download;
    RecordingsList.appendChild(li);
}

}, 3000);

};

</script>
</body>
</html>

here is the library to include:
https://github.com/mattdiamond/Recorderjs

dont forget to run this code on a real server otherwise it will not run
this code is a test, of course change it accordingly,
try to combine it with xsound it looks really awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants