I'm struggling to write just a simple HTML page with a form that takes an audio file as an input and passes it to a JavaScript file for manipulation.
What I Have
index.html
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<main role="main" class="container">
<form action="#" method="POST" enctype="multipart/form-data" class="audio-input-form">
<label>Audio File:</label>
<input accept="audio/*" type="file" name="audio_file"/>
<input type="submit" value="Get BPM" />
</form>
</main>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
app.js
// Package from NPM I import
import { analyze } from 'web-audio-beat-detector';
## here I want to be able to get and manipulate the audio data
Desired Result
When the form is submitted, I just want the actual file data to be available in the JavaScript file (I guess as an arraybuffer). I wish to turn it into an AudioBuffer using this tutorial but it's unclear to me how to actually pass the data off.
I tried making the form action a function in my JS file and using an onClick function as well but neither seemed to work. Would I need some form of an XHR? I'm confused as to their purpose, I don't want any kind of server running for this, just an HTML page and a JavaScript file that runs with it in the browser.
</body>tag I import my file calledindex.jsas<script src="/index.js"/>. In that file I have likefunction onSubmit(formData) { ... }but when I set the button to call that withaction="javascript:onSubmit(this)"I getonSubmitis not defined