Hi,
I am doing a math project for which I am trying to make sine models for some recorded sine waves. In order to do this, I need to convert audio e.g. wav into a table with time/sample and amplitude.
I have searched everywhere for a way to do this in Audacity or otherwise, but it has turned up nothing really except attempting to write my own program. Obviously this would take a long time as I have almost no programming experience.
Does anyone have any advice?
Thanks,
Tom
Exporting amplitude/time data for each sample
Forum rules
Audacity 1.2.x is now obsolete. Please use the current Audacity 2.1.x version.
The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
Audacity 1.2.x is now obsolete. Please use the current Audacity 2.1.x version.
The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
-
tomharding
- Posts: 1
- Joined: Wed Sep 30, 2009 4:39 pm
- Operating System: Please select
Re: Exporting amplitude/time data for each sample
For a MONO track only.
Select a bit of the track, then from the Effects menu choose the "Nyquist Prompt"
Enter this code into the box
Then press the "Debug" button.
It will display the values of the first 1000 samples in the selection.
The "time" value depends on the sampling rate of your audio. If the track has a sample rate of 44100Hz, that means that there are 44100 samples each second, so each sample will follow the previous one after 1/44100 second (0.000022676 seconds).
Note that this destroys the first 1000 samples of the selection.
If there are less than 1000 samples, results will be given for all available samples, and then an error is generated.
Select a bit of the track, then from the Effects menu choose the "Nyquist Prompt"
Enter this code into the box
Code: Select all
;; Read 1000 samples into array
(setf samplearray (make-array (snd-length s 1000)))
(do
((n 0 (setq n (1+ n)))
(nextsample (snd-fetch s) (setq nextsample (snd-fetch s))))
;; Exit when we run out of samples (nextsample is nil) and return the array "samplearray"
((eql n 1000) samplearray)
;; Start the execution part of the "do" loop
(setf (aref samplearray n) nextsample)
(princ (format nil "~a = ~a ~%" n (aref samplearray n))))
s
It will display the values of the first 1000 samples in the selection.
The "time" value depends on the sampling rate of your audio. If the track has a sample rate of 44100Hz, that means that there are 44100 samples each second, so each sample will follow the previous one after 1/44100 second (0.000022676 seconds).
Note that this destroys the first 1000 samples of the selection.
If there are less than 1000 samples, results will be given for all available samples, and then an error is generated.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Exporting amplitude/time data for each sample
If you need a version that does not destroy the samples:
Code: Select all
(setf s-in (snd-copy s))
;; Read 1000 samples into array
(setf samplearray (make-array (snd-length s-in 1000)))
(do
((n 0 (setq n (1+ n)))
(nextsample (snd-fetch s-in) (setq nextsample (snd-fetch s-in))))
;; Exit when we run out of samples (nextsample is nil) and return the array "samplearray"
((eql n 1000) samplearray)
;; Start the execution part of the "do" loop
(setf (aref samplearray n) nextsample)
(princ (format nil "~a = ~a ~%" n (aref samplearray n))))
s
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)