Sample Printer

Archive of Nyquist Plug-ins.
Many of the plug-ins here will be available on the Audacity Wiki.
Forum rules
This Forum is an archive of old topics concerning Nyquist plug-ins.

Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.

New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.

The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.
steve
Site Admin
Posts: 84904
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Sample Printer

Post by steve » Fri Jun 25, 2010 1:34 pm

A simple utility plug-in to print out the values of samples within the selected audio.

Downloads:
SamplePrinter.ny (obsolete version)
sample-data-export.ny (obsolete version)

FINAL VERSION sample-data-export.ny

NOTE: Sample Data Export is included in Audacity from version 2.0.1 onwards. Get the latest Audacity release here .

This is an "Analyze" plug-in (appears in the Analyze menu) which I made for testing purposes in another project.
It creates a simple html file that lists the sample values for the first x samples of the selection.
Do not set the number of samples too high or your computer will probably lock up (very memory hungry). Should be OK for up to a few thousand samples.
It is currently for mono tracks only.

[Update: The current version resolves the memory problems and may be used for mono or stereo tracks. Many additional enhancements - read this topic for full information]
Last edited by steve on Fri Apr 24, 2015 3:25 pm, edited 8 times in total.
Reason: Note that plug-in is in releases from 2.0.1 onwards.
Learn more about Nyquist programming at audionyq.com

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: Sample Printer

Post by Gale Andrews » Sat Jun 26, 2010 12:20 am

It probably needs an error forbidding more than 1000 samples. I had to reboot the computer even on 8000 samples on Win 7 x64.

Maybe info on the number of channels (when > 1 is supported) and the sample rate would be good to have in the file. I think it's more usual to have time offset information even though an ID number for each sample is handy.

Can you strip the opening and closing " out of the file?

Thanks


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 84904
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Printer

Post by steve » Mon Jun 28, 2010 12:04 am

Gale Andrews wrote:It probably needs an error forbidding more than 1000 samples
I'd rather not do that as the number of samples that can be processed is dependant on the available RAM.
I think that 1000 samples is a sensible limit for "average" computers, though some users that have heaps of RAM may want to process larger amounts of audio.
I've added a clear warning to the main interface.

The original version was intentionally very simple for 2 reasons - 1) because that was all that I needed when I wrote it, and 2) so that it would be easy for other users to modify for their own use. However, since you've asked.....
Gale Andrews wrote: Maybe info on the number of channels (when > 1 is supported) and the sample rate would be good to have in the file.
This new version supports mono or stereo tracks and has options for additional information in the output file.

Gale Andrews wrote:Can you strip the opening and closing " out of the file?
Yes.

Here's version 2 of the plug-in with the additional features.
This plug-in requires Audacity 1.3.x (it's a version 3 plug-in)

[Edit] Attachment removed - see next post
Last edited by steve on Fri Apr 24, 2015 3:25 pm, edited 2 times in total.
Reason: attachment removed - updated version in later post
Learn more about Nyquist programming at audionyq.com

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: Sample Printer

Post by Gale Andrews » Tue Jun 29, 2010 7:48 am

stevethefiddle wrote:
Gale Andrews wrote:It probably needs an error forbidding more than 1000 samples
I'd rather not do that as the number of samples that can be processed is dependant on the available RAM.
I think that 1000 samples is a sensible limit for "average" computers, though some users that have heaps of RAM may want to process larger amounts of audio.I've added a clear warning to the main interface.
Your call, but people who want to push the envelope could instead be made to change the ny file....

I noticed a small typo "dependant".
stevethefiddle wrote:This new version supports mono or stereo tracks and has options for additional information in the output file.


A few more ideas:
  • Maybe the path control example should be a Windows style path?
  • Maybe "Include track info" should be "include sample rate" (unless more features are coming like the track name?)
  • Stereo works fine but not of course split stereo, nor multiple mono tracks (each file is successively overwritten by that for the next track, leaving just the last file). Could it handle this better, or even produce one file per track?
  • Would text be a better output format?
Thanks for this.



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 84904
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Printer

Post by steve » Tue Jun 29, 2010 6:33 pm

Gale Andrews wrote:Your call, but people who want to push the envelope could instead be made to change the ny file....
I think that most novice users are likely to accept the limits of the slider range (many users do not even realise that values can be typed into the text box of slider widgets), but the dire warning at the top of the GUI should be sufficient to discourage reckless experimentation.
Gale Andrews wrote:I noticed a small typo "dependant".
Oops :oops: (spelling was never my strongest subject)
Gale Andrews wrote:Maybe the path control example should be a Windows style path?
Unfortunately back-slashes cannot be used with the current Audacity-Nyquist interface.
There was a discussion about the difficulty of setting paths in Nyquist on the audacity-nyquist mailing list last year http://audacity.238276.n2.nabble.com/Se ... 34136.html
In response to this issue Rodger Dannenberg updated Nyquist with the addition of an environment variable (getenv), but unfortunately Nyquist in Audacity has not been updated.
The best workaround that I can think of is to use forward slashes (which also worked on Windows last time I tested it).


Edgar highlighted an additional difficulty on Windows operating systems:
IMPORTANT: On MS Windows you cannot reliably re-construct the
user's HOME directory only by the username, because on Windows
the path of the HOME directory is localized:

In an english Windows the user's home directory is something like:
C:documents and settings[username]my files

In a german Windows the same home directory is something like:
C:Dokumente und Einstellungen[username]Meine Dateien
You have no doubt guessed that the default path used in this plug-in is set for my (Linux) computer.
Can you can suggest a better default path? One that works on Windows? (the old truncated 8.3 DOS file names may be required)
Gale Andrews wrote:Maybe "Include track info" should be "include sample rate" (unless more features are coming like the track name?)
When stereo tracks are analysed the output also prints which channel the data belongs to. This is omitted for mono tracks for obvious reasons.
Gale Andrews wrote:Stereo works fine but not of course split stereo, nor multiple mono tracks (each file is successively overwritten by that for the next track, leaving just the last file). Could it handle this better, or even produce one file per track?
It's possible, but until the problem with *SCRATCH* (property lists not surviving from one invocation to another) is fixed, then I'd rather stick with Rodgers advice
I
understand that the property list might not be working now, but it's a
bad idea to design on top of bugs.
The full discussion can be found here: http://audacity.238276.n2.nabble.com/Pa ... 68444.html

Gale Andrews wrote:Would text be a better output format?
Possibly for some applications it would, but for other cases XML may be better. The advantages of HTML are that text is easily formatted, easily displayed, there are no LF/CR confusions across different platforms, and the output can be easily copied and pasted from a web browser into text editor if plain text is required. The original version of this plug-in was deliberately rudimentary so as to be easy for users with little experience with Nyquist to tailor to their own requirements. The more complex the plug-in becomes, the harder it will be to do that. Although I'm happy to add useful functionality I'd like to keep the code relatively simple and easy to follow.

Thanks for the feedback and ideas Gale. The attached file has the spelling mistake corrected and the "dire warning" more prominent.
sampleprinter2.ny.zip
(1.09 KiB) Downloaded 377 times
(This replaces the previous version of sampleprinter2.ny.zip).
Learn more about Nyquist programming at audionyq.com

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: Sample Printer

Post by Gale Andrews » Wed Jun 30, 2010 9:23 am

stevethefiddle wrote:spelling was never my strongest subject
I found another typo "amout" (fixed in attached).
stevethefiddle wrote:Edgar highlighted an additional difficulty on Windows operating systems:
IMPORTANT: On MS Windows you cannot reliably re-construct the
user's HOME directory only by the username, because on Windows
the path of the HOME directory is localized
Can you can suggest a better default path? One that works on Windows? (the old truncated 8.3 DOS file names may be required)


Not really, and using truncated file names or ones that overflow probably won't help. However if this is to go public I don't think we can leave it as it is. For example if one just uses the current default, the confirmation will say it's been written to that default when of course it hasn't. Best suggestion I have at the moment is the attached "Unique, pre-existing output pathn(writes to current folder if empty/invalid)" with a suggested path of C:/ (or even leave the path empty). What happens on XP if the path is empty/invalid is that it writes to the Audacity folder the plug-in folder is in, unless you have written to a valid path previously in that session, in which case it reverts to that previous path if the path you enter is invalid.

stevethefiddle wrote:
Gale Andrews wrote:Maybe "Include track info" should be "include sample rate" (unless more features are coming like the track name?)
When stereo tracks are analysed the output also prints which channel the data belongs to. This is omitted for mono tracks for obvious reasons.
I still think "include sample rate" gives more idea what you'll get than "include track info" :)
stevethefiddle wrote:
Gale Andrews wrote:Stereo works fine but not of course split stereo, nor multiple mono tracks (each file is successively overwritten by that for the next track, leaving just the last file). Could it handle this better, or even produce one file per track?
It's possible, but until the problem with *SCRATCH* (property lists not surviving from one invocation to another) is fixed, then I'd rather stick with Rodgers advice
I
understand that the property list might not be working now, but it's a
bad idea to design on top of bugs.
Trouble with that is that it just looks like a bug unless you document it or maybe write the first track only if they select more than one.


Gale
Attachments
sampleprinter3.ny
possible solution to file naming ;info text/default path
(2.25 KiB) Downloaded 802 times
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 84904
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Printer

Post by steve » Wed Jun 30, 2010 5:07 pm

Gale Andrews wrote:I found another typo "amout" (fixed in attached).
Thanks.
Gale Andrews wrote:Best suggestion I have at the moment is the attached "Unique, pre-existing output pathn(writes to current folder if empty/invalid)" with a suggested path of C:/
That sounds as good as anything else. I prefer it to leaving the path empty as it at least gives a hint of the correct format.
Gale Andrews wrote:What happens on XP if the path is empty/invalid is that it writes to the Audacity folder the plug-in folder is in,
I think that is what should happen, but is frequently broken and goes to the modules folder instead. :(
Gale Andrews wrote:I still think "include sample rate" gives more idea what you'll get than "include track info"
OK, I've no problem with that. I'll change it in the next version.
Gale Andrews wrote:Trouble with that is that it just looks like a bug unless you document it or maybe write the first track only if they select more than one.
I've had an idea that may work and does not require the variable *SCRATCH* but I need to try it to find out if it works.
Learn more about Nyquist programming at audionyq.com

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: Sample Printer

Post by Gale Andrews » Tue Jan 25, 2011 1:07 pm

Steve, Sample Printer is proving popular with [email protected] enquirers. Unless you have a fix in progress for handling multiple tracks It may be good to bring it forward a bit for promotion to "Download Nyquist Plug-ins".

Feedback is pretty consistent on these points:

1) Option for text output is wanted. HTML is OK but not as only choice (the rationale is that text is easy to convert to a graph in a spreadsheet)
2) Output format descriptions unclear (you don't know if it's text, xml or whatever until you save, and wordings confusing)
3) Option wanted for sample rate with sample values only (so maybe a separate control for sample rate or not)?

One of my own - call it "Sample Data Export"?



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 84904
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Printer

Post by steve » Tue Jan 25, 2011 8:24 pm

Gale Andrews wrote:Sample Printer is proving popular with [email protected] enquirers
That's encouraging, and I find somewhat unexpected as there appear to be very few downloads from the forum.
Gale Andrews wrote:Unless you have a fix in progress for handling multiple tracks
That was a problem at the time due to *scratch* not working correctly, but I think that has now been fixed.
Gale Andrews wrote:3) Option wanted for sample rate with sample values only
Not sure what you mean :?
Gale Andrews wrote:"Sample Data Export"
Like it :P
Learn more about Nyquist programming at audionyq.com

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: Sample Printer

Post by Gale Andrews » Wed Jan 26, 2011 12:32 am

steve wrote:
Gale Andrews wrote:Sample Printer is proving popular with [email protected] enquirers
That's encouraging, and I find somewhat unexpected as there appear to be very few downloads from the forum.
I just attach the file to the e-mail as it's quicker.
steve wrote:
Gale Andrews wrote:Unless you have a fix in progress for handling multiple tracks
That was a problem at the time due to *scratch* not working correctly, but I think that has now been fixed.
The problem I had in mind was if you select multiple tracks the plug-in writes a file for each track, but overwrites to the same file name. Could it not do like export multiple and add a suffix to the file name for subsequent files in the same process, while still overwriting the file if it already exists?
steve wrote:
Gale Andrews wrote:3) Option wanted for sample rate with sample values only

Not sure what you mean :?
You can export a file that has sample values without indices, but not one like that which also has the sample rate.

Also I notice unless you choose "Include track info" it doesn't say which channel is which in a stereo track. For the HTML it might be nice for stereo to have the two channels side by side in a table.



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Post Reply