Page 2 of 9

Re: Convert Label text to LRC file

Posted: Wed Feb 12, 2020 9:17 am
by steve
bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
(with-open-file ...
Where did that come from?

bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
error: unbound function - WITH-OPEN-FILE
That means that the function "with-open-file" is unknown. It's not a valid function name.
The function you need for opening a file is "open". See: https://www.audacity-forum.de/download/ ... ef-190.htm

Re: Convert Label text to LRC file

Posted: Wed Feb 12, 2020 10:48 pm
by bigboss97
All good now. Thank you so much for your time.
steve wrote:
Wed Feb 12, 2020 9:17 am
bigboss97 wrote:
Wed Feb 12, 2020 6:20 am
(with-open-file ...
Where did that come from?
This is a macro in Lisp because I googled for Lisp commands :D

Re: Convert Label text to LRC file

Posted: Wed Feb 12, 2020 11:12 pm
by steve
Although Nyquist is a form of Lisp, it is based on a very small version of Lisp called XLisp. Other, bigger versions of Lisp (such as "Common Lisp") have many language features that are not part of XLisp.

The XLisp manual is here: https://www.audacity-forum.de/download/ ... -index.htm
The part of the XLisp manual that you will use most frequently is the Language Reference: https://www.audacity-forum.de/download/ ... -index.htm

Virtually all XLisp commands are valid in Nyquist. The (very few) XLisp commands that don't work in Nyquist are noted to that effect.
The XLisp manual is particularly helpful as it includes lots of examples.

Nyquist also has additional command that aren't part of XLisp. These are nearly all audio related functions, and can be found in the Nyquist Index: https://www.cs.cmu.edu/~rbd/doc/nyquist/indx.html

Re: Convert Label text to LRC file

Posted: Fri Feb 14, 2020 12:06 am
by bigboss97
Thank you so much, Steve.
I've bookmarked this thread. I'm sure I'll revisit all these information.

Re: Convert Label text to LRC file

Posted: Sun Feb 23, 2020 2:50 am
by bigboss97
Sorry, I have to come back and ask for help again :-) I did try to google and couldn't find any usable results.
My plug-in is now working, but it can't handle Unicode. How can I make it write Unicode file?

Code: Select all

(setq f (open fName :direction :output :if-exists :supersede))
*snip*
    (format f (if (string= (third label) "^") "~%[~a]" "<~a>~a<~a>") timeS (third label) timeE)))
(close f) 
I can see Export Labels have no problems in Unicode. I also tried to locate that plug-in without success. Is Export Labels a plug-in?

Re: Convert Label text to LRC file

Posted: Sun Feb 23, 2020 10:32 am
by steve
Nyquist doesn't support Unicode, only ASCII.
If you really must have Unicode support, then it may be possible to use read-byte and write-byte, but there are lots of ways that the code can trip up with Unicode.

Re: Convert Label text to LRC file

Posted: Mon Feb 24, 2020 4:13 am
by bigboss97
steve wrote:
Sun Feb 23, 2020 10:32 am
Nyquist doesn't support Unicode, only ASCII.
Does that mean when I retrieve the label (using Nyquist) the dual-byte information already lost? Which means I have no chance to write the unicode to a binary file. Is that correct?

Re: Convert Label text to LRC file

Posted: Mon Feb 24, 2020 10:00 am
by steve
bigboss97 wrote:
Mon Feb 24, 2020 4:13 am
Does that mean when I retrieve the label (using Nyquist) the dual-byte information already lost?
I had to check. The answer is yes. The "aud-get-info" command returns ASCII characters. Audacity converts multi-byte character to underscore ("_") before sending the data to Nyquist.

Re: Convert Label text to LRC file

Posted: Mon Feb 24, 2020 11:53 am
by bigboss97
steve wrote:
Mon Feb 24, 2020 10:00 am
The "aud-get-info" command returns ASCII characters. Audacity converts multi-byte character to underscore ("_") before sending the data to Nyquist.
Yes, I got underscores in my files.

That means I've no chance of building an unicode plug-in. Okay, then I need a plan B... :D
I can write a separate program to convert the exported label file to LRC. Is it possible to write a kind of macro to export the labels and then execute my converter? So the user can do all these in one step.

Re: Convert Label text to LRC file

Posted: Mon Feb 24, 2020 1:12 pm
by steve
You can get multi-byte characters from labels using "GetInfo: Type=Labels Format=JSON" via Python.
See here for the latest information about scripting with Python: https://alphamanual.audacityteam.org/man/Scripting
(That is actually the manual for Audacity 2.4.0, which is not yet released, but it's more up to date than the equivalent page in the 2.3.3 manual).