Text Editor Syntax Highlighting for Sforzando Instrument Files

In this post, we’ll learn how to configure text editor syntax highlighting for Sforzando instrument files with a few different text editor tools. Whether you use Mac, Windows or both, the editors and configurations will help you view your Sforzando instrument files with enhanced clarity. Why feel stuck with a common white background and black text when you can use these enhancements to add color and formatting to your text? Let’s get started!

19 June 2020 – Written by Michael R. Myers #mykmyrs

Skill Level: Intermediate

Choosing a Text Editor for Sforzando File

For the text editor software we’ll discuss, please note that all of the editors are cross-platform, except Notepad++ which is Windows-only. I included Notepad++ primarily because I have used it the most in my work life in an all-Windows environment. It’s well-supported and a preferred choice of other programmers like me while working in Windows.

At home I use mostly Mac for music production work, but there are times I am booted into Windows to use some specific software. While in Windows, I will sometimes work on my music and I need a text editor that supports both Windows and Mac. This post will show some of the recommended text editors that feature syntax highlighting additions regardless of your operating system environment.

The features we need to edit Sforzando instrument files are minimal, so feel free to try any or all of the suggestions I list in this article.

For file storage, I am keeping the text files on a cloud server that allows access from either Mac or Windows. You can use whichever service you like to store on the cloud, or keep your text files on an external drive. Whatever works for your workflow is good, just be sure that you can access the files when and where you need them.

This post is a tribute to the struggles I faced in figuring out how to get syntax highlighting working correctly for multiple editors in two operating systems. It will serve as a reference point for all of us moving forward.

What You’ll Need to Get Started

  • A text editor for your computer
  • A language definition file for your text editor
  • A great sample SFZ file from sfzformat.com to verify your language definition is working properly. Download the sample and save to your computer.

Download Free Text Editors to Highlight Syntax

Choose a text editor from the programs listed below to download and install it to your computer. You’ll also need the sample SFZ file downloaded as well. After you have installed an editor, we will download the language support files since they are different for each text editor.

Windows-Only

Notepad++ can be downloaded here. I used version 7.8.1 in this article.

Mac and Windows

This group of editors is the purpose for this blog post. I needed to find free and capable text editors that could also be extended to support syntax highlighting in both OSes.

  • Geany is available here. The latest version is 1.36.
  • CudaText is available here. The latest version is 1.105.0 (Win) or 1.99.0 (Mac)

Configuring Notepad++

After you download and install Notepad++, you’ll need to add support for a user-defined language. The language file, which is one *.XML file, is available for download here. Download the “sfz-udl.xml” to your computer. Follow the steps below to get NP++ set up.

  1. Open Notepad++ and load the sample SFZ file. By default, it will show the file contents as plain black text.NP-before-syntax_WM
  2. Click Language>User Defined Language>Define Your Language.
  3. Click the Import button. Navigate to your “sfz-udl.xml” file.
  4. Click OK on the Import Successful dialog window,
  5. Close the Define Your Language screen.
  6. Click the Language menu. At the bottom, click the new entry “SFZ”.
  7. Your SFZ file will now show with the language definition syntax in effect.NP-after-syntax_WM

Configuring Geany

Since Geany works in Mac and Windows, its configuration instructions depend on the operating system you’re using. Note that for either OS, you will need to enable the showing of hidden files and folders to find the Geany configuration locations.

Download the syntax highlighting files here. You’ll need two files: filetype_extensions.conf and filetypes.SFZ.conf. After downloading these files, follow the steps below for your OS.

Mac OS

  1. Open Geany and load the sample SFZ file. By default, it will show the file contents as plain black text.Geany-SFZ_before_Syntax
  2. Close Geany and open a new Finder window.
  3. In Finder, go to your user Home folder.
  4. Press Shift+Command+Period Key to enable the showing of hidden files and folders.
  5. Open the folder “.config/geany”. Place a copy of the downloaded file
    filetype_extensions.conf” into this folder.Finder-conf_Geany_folder_WM
  6. Open the folder “.config/geany/filedefs”. Place a copy of the downloaded file “filetypes.SFZ.conf” into this folder.Finder-SFZ_CONF folder_WM
  7. Open Geany and re-load your sample SFZ file.
  8. Click Document>Set Filetype>Miscellaneous. You will see “SFZ” as an available option. Click “SFZ” to select this language.Geany-Filetype_Menus_WM
  9. Geany will apply the syntax highlighting and you will see that the tags within the sample file have changed colors.Geany-SFZ_after_Syntax_WM

Windows 10

Follow the instructions for Mac as written above, substituting Windows Explorer for Finder to browse for files.

For Step 4, tick the checkbox in the Windows Explorer menu bar to show hidden files.

For Step 5, copy “filetype_extensions.conf” to folder C:\Users\{USER_NAME}\AppData\Roaming\geany.

For Step 6, copy “filetypes.SFZ.conf” to C:\Users\{USER_NAME}\AppData\Roaming\geany\filedefs

Configuring CudaText

CudaText works the same in Mac and Windows for importing language support. CudaText’s approach to importing the language definition files is as easy as File>Open and selecting the file to load. There is no need to show/hide folders or manually copy files. Great job on this type of easy implementation, CudaText developers.

  1. Unzip program file to location of your choice
  2. Run CudaText and load your sample SFZ file. As shown, it’s just black text.CudaText-SFZ_before_Syntax_WM
  3. Use File>Open file to open the SFZ Lexer file. When prompted to install it, click OK. Click OK again after the installation completes.
  4. Click View>Lexers and scroll down in the list to select “SFZ”. Your text should automatically show syntax highlighting.CudaText-SFZ_after_Syntax_WM

Summary

Thanks to some great developers, there are several free text editors available that support syntax highlighting of Sforzando instrument files. Adding syntax highlights makes the job of editing text configuration files much easier. With some advanced skills, you can customize the language definitions to your own liking to really make the color schemes work for your own preferences. In addition, these cross-platform editors, along with a centralized storage area, make it much easier to work in Windows and Mac when the need arises.

If you would like to add to this content to help other folks, please contact me and let me know what you have in mind.