Author Topic: Creating a Sound Resource Library for VoiceAttack  (Read 13303 times)

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2800
Creating a Sound Resource Library for VoiceAttack
« on: November 17, 2019, 03:20:00 PM »
This is the short how-to guide for building and using a sound resource library for use with VoiceAttack (as referenced in the help document's 'Play a Sound' action section - current beta).


Open Visual Studio (for demonstration purposes, I'm using Visual Studio 2019).  Click on, 'Create a new project' and select, 'Class Library (.NET Framework). <- This is important - do not chose .NET Core or .NET Standard.

Then, click, 'Next'.

Name your class library, choose your location and solution name.  Make sure your Framework version does not exceed the
framework version of VoiceAttack.  Choose .NET Framework 4.5 just to be safe ;)

Click, 'Create'.

Over on the right, in, 'Solution Explorer', right-click and delete, 'Class1.cs' from the project (you won't be needing it).

In the main menu, click on 'Project' and then your project's properties (usually the last item in the menu).

In the properties menu on the left, click on Resources.  In the middle of the screen, you may see a link that says, 'This project does not contain a default resource file.  Click here to create one.'  Click this link.

You'll then be presented with a new menu.  Change the, 'Access Modifier' value from, 'Internal' ('Friend' if this is a VB.net project) to 'Public'.

Click the down arrow next to the, 'Add Resource' menu item.  Select, 'Add Existing File'.

Browse to and select the sound file (.wav, .mp3, etc) that you want to add as a resource.  After you've selected the sound file, you'll see it displayed as a resource in the resources display.  Note how this resource is named - try to be consistent (you'll thank yourself later).

Repeat adding more files as needed.  Again, make note of the naming.  Also note that .wav files will show up as an, 'audio' resource, and .mp3 files (and other sound files that have formats that are not .wav) will show up just as, 'file' resources.  This is OK, as VoiceAttack will look for both.

Make sure to set up all your assembly info and fun stuff in the, 'Application' properties (menu over on the left side).

Save your solution (well, you probably should have been saving all along).

You should now be able to build your library.

In VoiceAttack, just browse to your new .dll from the, 'Play a sound' or 'Play a Random Sound' action screens.  You'll want to append a, '?' to the end of the path, plus the name of a resource you just added.  So, if the sound resource was called, 'rockets' (since you named it like that - consistently), and the new library you just compiled is named, 'myResource.dll' your full path would look something like this: "C:\path to my resource file\myResource.dll?rockets" (without the quotes).  When VoiceAttack encounters a, '?' in the path, it first searches for what is to the left of the, '?' as the path to the library and then searches that library for a resource named whatever is to the right of the, '?'.


Attached is a sample project with three included .wav files.  Just load the solution and compile.  Also attached is a profile with one command that will play the sounds.  Just modify the, 'Play a Sound' actions to have the proper path to the resource dll and you'll be all set.
« Last Edit: April 16, 2020, 11:15:33 PM by Gary »