Link a custom Audio File's Signature to a custum Plugin

Started by mamnsi,

mamnsi

Hello,
Our school has a student-run Radio DJ workshop. To discourage students from stealing/copying our WAV files, my idea is to "encrypt" our WAVs to ".foo" (e.g., simply by inverting the bits because WAV is uncompressed).

I created a new custom BASS plugin, `bass_foo.dll`, which exports:
* BASS_FOO_StreamCreateFile
* BASS_FOO_StreamCreateFileUser
* BASSplugin

I know that BASS uses the file signature (not the *.foo extension) to select the correct plugin. My question is: how do I give BASS the signature so that the BASS_FOO_StreamCreateFile function is called when playing "foo" music?

To do my tests, I created a small player in C# with Bass.Net which loads the plugins (I confirm that `bass_foo.dll` is loaded) then it tries to read a file "music.foo", but there I have the error BASS_ERROR_FILEFORM because the signature does not exist.

A little help would be really nice. Thank you.

Ian @ un4seen

It sounds like you want BASS_StreamCreateFile to automatically use your plugin for "foo" files instead of having to call BASS_FOO_StreamCreateFile separately? If so, you need to load your plugin via BASS_PluginLoad, and your BASSplugin function will then be called (with BASSPLUGIN_CREATE) by BASS_StreamCreateFile to check if it can handle a file. You won't really need either of the BASS_FOO_StreamCreateFile and BASS_FOO_StreamCreateFileUser functions for this.

mamnsi

Thank you very much for this reply. With your instructions, I was able to play my "musique.foo" file (I hear the original sound on my little C# player).
My new problem is when I try to import the FOO file into Radio DJ. I'm blocked by a TagLib exception.
Is there a way to have *.foo validated by TagLib?

A little clarification:
In fact, I don't encrypt (bit-reverse) the first bytes in order to preserve the information from the original WAV, so the tags are there. But I'm changing the "RIFF ... WAVE" signature to a FOO signature so that bass_foo.dll does the reading.

Another clarification:
Radio DJ didn't include *.foo in the list of supported formats, but that's okay; I'm using "All files."

Here's the TagLib exception:
musique.foo (taglib/foo)   à TagLib.File.Create(IFileAbstraction abstraction, String mimetype, ReadStyle propertiesStyle)
   à rdjInterface.Tracks.get_ID3CueData(String filePath)
   à tpqeR|CbPrcpdnE986\,-#8q1".‎‏��‮‫�‬�‭�‫�‭‮�‫‬‪‌����‮‭‫�‎�‫�‏‌�‮()
   à tpqeR|CbPrcpdnE986\,-#8q1".‎‪���‎‫�‏��‮‎‮‪����‭‫‭�‏‏‫�‏�‌‏�������‭‮(Object , EventArgs )
   à System.EventHandler.Invoke(Object sender, EventArgs e)
   à System.Windows.Forms.Control.OnClick(EventArgs e)
   à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Ian @ un4seen

I'm not familiar with TagLib so I'm afraid I'm unable to advise on that. If it needs the file to be "RIFF ... WAVE" then perhaps you could keep that and instead use a custom wFormatTag value in your file's "fmt " chunk? Note that if you want tagging software to be able to parse your files then you should only be encrypting the sample data, and not the chunk headers.