Need help making a plugin, have no Nyquist knowledge...

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
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
Post Reply
edale
Posts: 8
Joined: Wed Oct 04, 2017 12:57 am
Operating System: Windows 10

Need help making a plugin, have no Nyquist knowledge...

Post by edale » Mon Dec 21, 2020 5:32 pm

Hi, I'm trying to make a simple plugin that will let me drag-and-drop .PCM files with a non-standard header into Audacity, rather than having to "import raw data" every time. The problem is I don't know anything about Nyquist, and have no programming skills...

It was suggested I get help here when I opened an issue on the Audacity GitHiub: https://github.com/audacity/audacity/issues/702

What the plugin would need to do is when a .PCM file is dropped into audacity, it would check the first 4 bytes of the file for the header "MSU1" (Hex: "4D 53 55 31"), and if it has that header it imports the file with the following settings:

Encoding: Signed 16-bit PCM
Byte Order: Little-endian
Channels: 2-Channels (Stereo)
Start Offset: 8 bytes
Amount to Import: 100%
Sample Rate: 44100 Hz

On the GitHub it was suggested this would be possible with the "S-READ" command.

Any help with this would be appreciated, I don't even know where to start...

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Mon Dec 21, 2020 6:19 pm

edale wrote:
Mon Dec 21, 2020 5:32 pm
Hi, I'm trying to make a simple plugin that will let me drag-and-drop .PCM files with a non-standard header into Audacity, rather than having to "import raw data" every time.
Nyquist plug-ins do not support drag-and-drop, but I think it should be possible to create a plug-in that allows you to select a MSU1 file (via a file browser window) and import it (similar to using the normal "Import" from the File menu).

Could you post a short MSU1 file (less than 1MB) for me to try?
You may need to add ".wav" to the file name for the forum to allow it. See: viewtopic.php?f=49&t=64936
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

edale
Posts: 8
Joined: Wed Oct 04, 2017 12:57 am
Operating System: Windows 10

Re: Need help making a plugin, have no Nyquist knowledge...

Post by edale » Tue Dec 22, 2020 12:48 pm

steve wrote:
Mon Dec 21, 2020 6:19 pm
edale wrote:
Mon Dec 21, 2020 5:32 pm
Hi, I'm trying to make a simple plugin that will let me drag-and-drop .PCM files with a non-standard header into Audacity, rather than having to "import raw data" every time.
Nyquist plug-ins do not support drag-and-drop, but I think it should be possible to create a plug-in that allows you to select a MSU1 file (via a file browser window) and import it (similar to using the normal "Import" from the File menu).

Could you post a short MSU1 file (less than 1MB) for me to try?
You may need to add ".wav" to the file name for the forum to allow it. See: viewtopic.php?f=49&t=64936
Here's a little 3 MB MSU1 format PCM that I provided in the GitHub issue:
https://github.com/audacity/audacity/fi ... _msu-1.zip
If that's not suitable, I can whip up a shorter clip of something, I think I have some short SFX tracks I've used in some MSU projects...

I have a bit more technical info about the format (such as a screenshot of the header in a hex editor) in the GitHub issue: https://github.com/audacity/audacity/issues/702

Do any of Audacity's supported plugin types support drag-and-drop?

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Tue Dec 22, 2020 4:50 pm

edale wrote:
Tue Dec 22, 2020 12:48 pm
Do any of Audacity's supported plugin types support drag-and-drop?
Not as far as I'm aware.
edale wrote:
Tue Dec 22, 2020 12:48 pm
Here's a little 3 MB MSU1 format PCM that I provided in the GitHub issue:
Super - I'll have a play and get back to you.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Tue Dec 22, 2020 7:35 pm

I assume from your description that MSU1 files are always stereo, so I've written this for stereo MSU1 files only.
I also assume that the sample rate is always 44100.

Unfortunately there's a few limitations that I had to workaround, but hopefully this is still useful for you.
  • You must select a stereo audio track to import into.
    "Tracks menu > Add New > Stereo Track" to create a new stereo track.
    If you are doing this frequently, you could set up a keyboard shortcut - see: https://manual.audacityteam.org/man/key ... ences.html
  • The audio is always imported as 44100 Hz sample rate, so the track must be 44100 Hz sample rate.
    Audacity's default sample rate is 44100 Hz, so you would not normally need to do anything about this.
  • The maximum length that can be imported is about 2.7 hours.
    I assume that this is plenty long enough.
  • Drag and drop is not possible.
Here's the Nyquist plug-in:
MSU1-Importer.ny
(972 Bytes) Downloaded 52 times
Instructions for installing on Windows: https://manual.audacityteam.org/man/ins ... st_install

When installed and enabled, it will appear in the "Tools" menu (requires Audacity 2.4.2 or later).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Wed Dec 23, 2020 12:43 pm

steve wrote:
Tue Dec 22, 2020 7:35 pm
Here's the Nyquist plug-in:

MSU1-Importer.ny
(972 Bytes) Downloaded 5 times
Anyone care to post feedback? Does it work for you?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

edale
Posts: 8
Joined: Wed Oct 04, 2017 12:57 am
Operating System: Windows 10

Re: Need help making a plugin, have no Nyquist knowledge...

Post by edale » Fri Dec 25, 2020 3:18 pm

steve wrote:
Wed Dec 23, 2020 12:43 pm
steve wrote:
Tue Dec 22, 2020 7:35 pm
Here's the Nyquist plug-in:

MSU1-Importer.ny
(972 Bytes) Downloaded 5 times
Anyone care to post feedback? Does it work for you?
Sorry, the site's been a bit unstable (whole audacityteam.org site, not just the forum), and I kept getting 404 error messages while trying to check things. Seems to be working normally for now though.

Had some fun times getting Windows to let me copy the plugin into Audacity (they've really locked down the program files folder in Win10, lol), but with the file in place, the plugin installed, and things tested...

It seems to work as advertised.
It imports the MSU1 format .PCMs.
It cuts off the leading 8-bytes, so the header doesn't get interpreted as audio data.
Bit rate and sample rate are both correct, so everything plays back at the proper speed and pitch.

---

It's not an ideal solution. When working edits to just one or two files it may still be quicker to import raw data, thanks to the extra step of creating a blank stereo track to import into. However, this seems to be more a limitation of the plugin system, rather than a design flaw in the plugin.

That said, when I'm doing work on a large number of tracks, and I can import one track, edit it, save the changes (and run it through the not-related-to-audacity tool that converts it from WAV into MSU1 PCM), then delete it and import the next one, rinse-repeat... In that case it should give me a pretty decent time-save (since I'd only need to create the blank track once, and I'm usually doing that with batches of dozens of files).

All in all, I'd say this will be helpful to me, but falls slightly short of what I was hoping for due to the limitations of the plugin system.

May I have your permission to share this plugin on the Zeldix forums (pretty much the central hub for MSU-1 mods and development, despite nominally being a Zelda-centric forum)?

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Fri Dec 25, 2020 4:57 pm

edale wrote:
Fri Dec 25, 2020 3:18 pm
the site's been a bit unstable
Yes, there's recently been some changes to the web server. It should be much better now.

edale wrote:
Fri Dec 25, 2020 3:18 pm
the extra step of creating a blank stereo track to import into
I hoping that eventually it will be possible for Nyquist plug-ins to do that part, but for now it has to be done manually. You can however create a keyboard shortcut to create a stereo track which may be just a little bit more convenient (see: https://manual.audacityteam.org/man/key ... ences.html)

edale wrote:
Fri Dec 25, 2020 3:18 pm
May I have your permission to share this plugin on the Zeldix forums
Certainly. The plug-in is under terms of the open source "GNU General Public License version 2" https://www.gnu.org/licenses/old-licens ... .0.en.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

edale
Posts: 8
Joined: Wed Oct 04, 2017 12:57 am
Operating System: Windows 10

Re: Need help making a plugin, have no Nyquist knowledge...

Post by edale » Fri Dec 25, 2020 6:49 pm

steve wrote:
Fri Dec 25, 2020 4:57 pm
edale wrote:
Fri Dec 25, 2020 3:18 pm
May I have your permission to share this plugin on the Zeldix forums
Certainly. The plug-in is under terms of the open source "GNU General Public License version 2" https://www.gnu.org/licenses/old-licens ... .0.en.html
Still always polite to ask. :D

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

Re: Need help making a plugin, have no Nyquist knowledge...

Post by steve » Fri Dec 25, 2020 8:16 pm

:D
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply