Automatic Frequency Generation by Spreadsheet?
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Automatic Frequency Generation by Spreadsheet?
Hi, i'm not sure if this is the proper place to ask so excuse me if this belongs to somewhere else.
I am looking for a possibility to automatically generate multiple sinus waves (or rather - a sound) with different amplitudes, based on a spreadsheet (containing frequency and amplitude) and each with a random phase offset. Is there a plugin or an easy way to do that for a "luser" in audio editing like me? ^^
The background is the following - i have the frequency spectrum of gear combinations (transmission) through numerical calculations in spreadsheet format and i'd like to "audiolise" (visualising for the ears so to speak) the results
I am looking for a possibility to automatically generate multiple sinus waves (or rather - a sound) with different amplitudes, based on a spreadsheet (containing frequency and amplitude) and each with a random phase offset. Is there a plugin or an easy way to do that for a "luser" in audio editing like me? ^^
The background is the following - i have the frequency spectrum of gear combinations (transmission) through numerical calculations in spreadsheet format and i'd like to "audiolise" (visualising for the ears so to speak) the results
-
Robert J. H.
- Posts: 3633
- Joined: Thu May 31, 2012 8:33 am
- Operating System: Windows 10
Re: Automatic Frequency Generation by Spreadsheet?
That's no problem.
You can directly produce executable code within the spreadsheet and paste in the nyquist prompt to produce a sound in Audacity.
What program do you use? I'm only familiar with Excel.
However, the formulas needed are so simple that it will be the same in most applications.
Let's say we have frequency in A2:An and Amplitude in B2:Bn and the duration would be 1 s:
C1:
C2:
The same formula for all up to Cn.
Cn+1:
Don't forget the equal signs.
As you can see, the phases are randomized on the fly.
I've written it adhoc, so there might still be a mistake in it.
All you have to do afterwards is copying the C1:Cn range, put it in the Nyquist Prompt (Effect menu) and press OK.
You can directly produce executable code within the spreadsheet and paste in the nyquist prompt to produce a sound in Audacity.
What program do you use? I'm only familiar with Excel.
However, the formulas needed are so simple that it will be the same in most applications.
Let's say we have frequency in A2:An and Amplitude in B2:Bn and the duration would be 1 s:
C1:
Code: Select all
="(abs-env (sim"Code: Select all
=" (scale "&B2&" (hzosc "&A2&" *table* (real-random 0 360)))"Cn+1:
Code: Select all
="))"As you can see, the phases are randomized on the fly.
I've written it adhoc, so there might still be a mistake in it.
All you have to do afterwards is copying the C1:Cn range, put it in the Nyquist Prompt (Effect menu) and press OK.
Re: Automatic Frequency Generation by Spreadsheet?
Great! Thank you, it works perfectly.
Is there a way/workaround to increase the maximum amount of lines the nyquist window can take at once? It cuts off the pasted code if there are more then ~500 lines
Is there a way/workaround to increase the maximum amount of lines the nyquist window can take at once? It cuts off the pasted code if there are more then ~500 lines
-
Robert J. H.
- Posts: 3633
- Joined: Thu May 31, 2012 8:33 am
- Operating System: Windows 10
Re: Automatic Frequency Generation by Spreadsheet?
I think the text box limit is about 32768 characters.X3KJ wrote:Great! Thank you, it works perfectly.
Is there a way/workaround to increase the maximum amount of lines the nyquist window can take at once? It cuts off the pasted code if there are more then ~500 lines
Thus the limit is not defined by actual lines.
How many sine waves do you intent to sum up?
You can use the variable "s" to add the existing audio in the track to the new ones.
E.g.
Code: Select all
="abs-env (sim s"You would copy the first 300 cells, put it in the nyquist prompt, append to parenthesis '))' and create the tone with ok.
Then, you would copy the next 400 cells and overwrite all after "sim" in the Nyquist Prompt with the copied cells. Don't forget to place the variable s somewhere (after sim for example).
There are several methods to make the code more consise.
For example (for the Nyquist Promt):
Code: Select all
(defun accumulate (duration list)
(abs-env (stretch-abs duration (simrep (i (/ (length list) 2))
(scale (nth (1+ (* 2 i)) list)
(hzosc (nth (* i 2) list) *table*
(real-random 0 360)))))))
;;
(accumulate 2.0; duration in seconds
(list
>Overwrite me with the two copied columns, freq&>
))You can also change the duration (2 s, after "(accumulate")
Store the code also in the spreadsheet in order to have it handy.
Too many sine waves may cause a stack overflow--no warranty
Re: Automatic Frequency Generation by Spreadsheet?
If that is the case on your machine, then it may be platform dependent, or it may not just be a character count limit.Robert J. H. wrote:I think the text box limit is about 32768 characters.
I've just tried pasting code into the Nyquist Prompt effect which included 4 extremely long comments (> 30000 characters per comment) with simple PRINT commands between. The PRINT commands were all correctly executed, and all of the data (including comments) was correctly retained in the text box when I reopened the effect.
The total character count for this experiment was 153568 characters.
For huge amounts of data, it would really be better to read from a file.
Update: successfully repeated the above test with > 1.2 million characters.
Update: Also works with > 5 million characters, though it is becoming very slow to scroll down the text box.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
Robert J. H.
- Posts: 3633
- Joined: Thu May 31, 2012 8:33 am
- Operating System: Windows 10
Re: Automatic Frequency Generation by Spreadsheet?
It's a bit strange.steve wrote:If that is the case on your machine, then it may be platform dependent, or it may not just be a character count limit.Robert J. H. wrote:I think the text box limit is about 32768 characters.
I've just tried pasting code into the Nyquist Prompt effect which included 4 extremely long comments (> 30000 characters per comment) with simple PRINT commands between. The PRINT commands were all correctly executed, and all of the data (including comments) was correctly retained in the text box when I reopened the effect.
The total character count for this experiment was 153568 characters.
For huge amounts of data, it would really be better to read from a file.
Update: successfully repeated the above test with > 1.2 million characters.
Update: Also works with > 5 million characters, though it is becoming very slow to scroll down the text box.
First pasting of an Excel column (line-numbers as content)
stops after 5184 lines = 30000 characters.
I then select all the text (ctrl-home and ctrl-shift-end) and paste again.
This pastes all 1048576 lines = ~8000000 characters.
Then Ok (with the SAL error message coming up).
..reopen...
Now, I can only jump from Ok to Cancel to Debug (tab key).
Re: Automatic Frequency Generation by Spreadsheet?
The Nyquist Prompt was designed to handle short snippets of code, so it doesn't surprise me if there are quirks/bugs when pasting tens of thousands of characters, but it seems OK here (on Linux) for hundreds of thousands of characters.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: Automatic Frequency Generation by Spreadsheet?
If this code is for a one off job, it would probably be easiest to just save the data as a plain text file on the desktop, then hard code the path to the file into the Nyquist script.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
Robert J. H.
- Posts: 3633
- Joined: Thu May 31, 2012 8:33 am
- Operating System: Windows 10
Re: Automatic Frequency Generation by Spreadsheet?
I assume that it is rather a screen reader issue on my system.
WXWidgets do not behave very well under certain circumstances, in particular when it comes to accessibility requirements and compatibility. .
WXWidgets do not behave very well under certain circumstances, in particular when it comes to accessibility requirements and compatibility. .