Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

how to use bfxr?

3 Answer(s) Available
Answer # 1 #

Many people want to create audio sounds or music with computers, but do not know how to code. This article is for them. I will show you a way to start experimenting with sound design without software, and then I will show you an easy way of creating sound effects with software.

This article will be split into two parts: the first part about designing audio in a non-linear fashion, and the second about generating sound effects with bfxr (a free program).

In the first section, we discuss NFTs (non-functional transforms). It seems strange that there would be no function in this type of transform yet it’s still useful for making complex sounds. The way this works is by using an LFO (Low-Frequency Oscillator) to combine multiple parameters at once.

In the second section, we will use bfxr to generate sound effects. Bfxr is easy, it’s quick, and it and open source so you can use it freely in your games and apps.

I will first explain what an NFT is and how it’s different from other transforms. After that, I will discuss the benefits of using NFTs in the creation of designed audio, followed by a discussion of a possible disadvantages of using this type of transform.

In the Naughty Dog’s article Achieving Authentic Soundscapes Shawn Purdy talks about how understanding the way sound behaves in video games can lead you to new and unique ways of creating sound design. To understand how to manipulate these sounds I highly recommend reading this article. Understanding the entire article is not required, but it’s a good read. For this explanation, I will be using what Shawn describes as an “NFT” (Non-Functional Transform). An NFT is a transform that has no functions, but can still be used to achieve specific results. It is composed of multiple parameters that can be multiplied into a single number.

In the image below, an NFT is constructed that has two parameters, an LFO (low-frequency oscillator) and a filter. The LFO controls the speed of randomization, and the filter controls how intense the randomization will be at each step. For example, if you wanted to make a sound effect that was constantly fluctuating in pitch, you would set your LFO to a high rate and set your filter to 100%, meaning all of the signals will reach the output. You could experiment with making sounds by changing these values and seeing how they affect other aspects of sound design on your computer or even in real life.

The flexibility of randomization: An NFT is very flexible in the way that any value can be input into it, and any value can be output. This means that you could use an NFT to generate a random value for each interrupt. In this way, you would call the NFT with a new number each time, and it will output a different number each time. This type of transformation could be used to make very complex sounds. Control over different aspects of sounds: NFTs can increase or decrease the effectiveness of certain types of sound design on your soundscape. For example, if you were making a track for an arcade racing game, you might want to make the engine sound faster and more frantic with an NFT. This would give your car a sense of speed by speeding up the pitch, but also increasing its loudness with the increase in speed. You could also make other aspects such as the reverb quieter or softer so that it doesn’t distract from other sounds on your level.

There is one possible disadvantage to using an NFT: It can be difficult to find a use for them when making/creating music. You would rather have a parameter that controls the pitch and another that controls the volume than have to create an NFT to control both. But for sound effects, it is very useful. You can use an NFT to control the mix of different sounds in a game, or you could use it to control which random sound is chosen each time a random sound plays. In this way, you could design an interesting track by playing a certain type of sound after another certain type of sound at different times.

Strength: 100% Normal value: 123 Volume: 0% Speed: 0%

Bfxr is a free program used to make retro sounds and effects, with many presets already provided. In the video below you can see it used to record ambient sounds and then to create a sound effect. The same thing could be done with NFTs, but it would be less complicated. It is very easy to use bfxr, so if you want to learn more then I recommend reading this article on making bfxr sound effects.

Make a new audio file by right-clicking on bfxr and selecting “New Sound Effect” (or File>New Sound Effect). This will open up the file in BFXR which is a text editor, where every line represents one parameter of an NFT. Each line has several parameters that can be edited, and they are separated by semicolons. For example 1;2;3 represent three parameters all with the same value of 2. There are also other characters such as brackets and commas which you can use to make your audio sound different. These will be explained in the article mentioned above. Inside the BFXR editor, you can see that there are different tabs for audio recording (left), editing (right), and export/compile (top). The audio of your new file will not be saved as an .ogg or .wav file. Instead, it will be saved as a text file. You can edit this text with any text editor. To add effects to your sound file, you have to go to the export/compile tab and choose “FX” tab. This will open up another text editor where you can save your file.

To make sounds, change the number at the top of each line in the variables tab. For example, if you want to make a sound that has a pitch of 440Hz, set the first number to 0 and the second number to 440. If you want to make a sound that is louder than normal, add or subtract the first value from the second value.

I will guide you through how to create an NFT as follows:

Make a new audio file by opening bfxr and clicking on New Sound Effect (or File>New Sound Effect). This will open up your file in bfxr where all lines are numbers with two values separated by commas. These numbers represent sound parameters. The first value will be the input value, and the second value is the output value. Click on File>Save As… to save your file as a text file. A new tab will appear that is called “Main”, make sure this tab is empty before writing your NFT. You should now see: 0;0;0;0;0;0;0 Copy and paste this line into the Main tab with {brackets}. This means that each bracket represents a semicolon in your bfxr editor. The semicolon represents a comma in bfxr, so your line will now look as follows: 0;{bracket}0;{bracket}0;{bracket}0;{bracket}0;{bracket}0;{comma}.

You can add more lines to your NFT by clicking on the + sign at the top of the editor. Add these lines in this order. The first number in a line should always be the first number in your previous line, and the second number in a line should always be the second number in your previous line. If you want to add two different parameters and only want one to be random, you can use this format: All parameters default: {bracket}0;{bracket}0

Parameter 1 random: {bracket}123

Parameter 2 random: {bracket}456 Now when you playback your file with bfxr, then all of these parameters will be set to values randomly chosen. You can edit these values by clicking on the File>Open Main tab. Add the following lines to your NFT. The first number should always be the first value in your previous line, and the second should be the second: 1;2;3 Each number represents a different parameter in your bfxr file, and you can use semicolons to separate parameters. If you want to make things more complicated, you can add more parameters. For example 1;{bracket}2;;3;;4;;5;;6 These numbers represent: pitch (1), volume (2), speed (3), distance (4), panning (5), reverb loudness (6)

Parameters that don’t have an input value will randomly pick a whole value between 0–100%. For example, if you make a line as follows: 1;2;3;4; This will randomize by picking between 0–100% for each parameter.

If you want to know how to use the other characters in bfxr, read the article mentioned above.

Here is an example of how you would use BFXR to create an NFT:

To save your results as an .ogg or .wav file, open up a new tab and write whatever name you want for your .wav or .ogg file. You can then open it with BFXR when you are done creating your NFT. Remember that every time you save your file with File>Save As… you will lose all the changes you have made.

I will guide you through how to create an NFT as follows:

Make a new text file by opening bfxr and clicking on File>New Sound Effect (or File>New Sound Effect). This will open up your file in BFXR where all lines are numbers with two values separated by semicolons. These represent the parameters of your NFT. The first value is the input value, and the second value is the output value. Copy and paste this line into the Main tab with {brackets}. This means that each bracket represents a semicolon in your bfxr editor. The semicolon represents a comma in bfxr, so your line will now look as follows: 0;{bracket}0;{bracket}0;{bracket}0;{bracket}0;{bracket}0;{comma}.

[2]
Edit
Query
Report
Cyril Beckwith
Structure Maintainer
Answer # 2 #

This article doesn’t require any PD knowledges but some features like controls and load/save require some advanced PD knowledges and are covered in the article appendix for a full comprehension of the final patch.

Note that we won’t respect all BFXR implementation, we’ll follow the main principle but takes some liberty for parameters range and organization. Not all BFXR features will be implemented here and we’ll add some extra features as well.

You can download patch version at each step in this tutorial in order to understand the progression but you can download the final application as zip file here. Just extract it and open the pfxr.pd file and smoke it :-).

Let start with a basic sin waveform and a decay :

download

To emulate BFXR we will introduce GUI slider to control a full Attack/Sustain/Decay (ASD) envelop.

download

Our patch will get a lot of control and we need something simpler to maintain. We can make reusable modules with PD, these modules are called “Abstraction”.

Abstraction can just contains processing object but could have a GUI as well. Since this abstraction involve advanced PD knowledge, we will use it as-is, full explanation is available in appendix. Futhermore this abstraction will contains more features for storage, randomization, … and its implementation is beyond the scope of the heart of this article.

We name it “control” and pass it few parameters :

For instance in our patch we create a control named “attack-time”. When we change its value, the abstraction will send a global message to symbol “attack-time”. In our main patch these messages can be obtain with the receive object (r attack-time)

Note that an abstration is a separated file and you will need to download this file to the same folder as other pd files.

Then we adapt our patch to use the control abstraction for the previously created ASD controls. Note that “control-change” message trigger the sound now!

download

Another nice feature is to view the wave form

download

OK enough with GUI, lets back to the sound!

download

BFXR provides 9 waveforms :

In order to control what we’re doing we will add a visializer for our waveform shape.

download

Our path become messy and since we had a lot of things to add, we will refactor it a little by separating things.

We already know abstractions but pd provides another kind of custom object know as “subpatch” it is used to group object together to have cleaner patch. Lets group logical things :

Our ASD subpatch :

And our wave form sampler :

And the result is really cleaner you don’t think ?

download

Let’s create the saw signal and the waveform switch controller. Again to simplify, we will group all waveforms in a subpatch.

Here is our final patch :

download

Here is our waveforms selector :

Here is our previously sin. Note that we introduced a switch~ objetct. This ensure to not process audio when DSP is off. It saved some CPU.

And finally our saw signal :

TODOC

TODOC

TODOC

TODO : ???

This effect is not part of BFXR/SFXR but it’s simple, easy to understand and an interesting effect.

The tremolo is a low frequency signal which modulate the whole sound amplitude. To have a natural tremolo, we’ll use a sinusoid signal (osc~).

The depth is how much modulation is apply to main signal. Look at the output signal curve, we can visualize the LFO (Low Frequency Oscillator) effect.

Look at the output signal curve, we can visualize the LFO (Low Frequency Oscillator) effect.

And below you can see how we integrated in our patch :

download

Vibrato effect is closed to tremolo but apply to frequency instead of amplitude. This effect simulate violin vibrato when player oscillate his finger which produce a tiny modulation of string length and then frequncy. Guitarist knows well this effect with use of mecanical vibrato or bending the strings with their fingers.

Again for a natural vibrato we’re using a sinusoidal signal. The depth is how much modulation is apply to main frequency we control so far.

Here is our vibrato subpatch. Note that this time we won’t connect any portlet to/from our vibrato but use a named signal instead. This work like messages send and receive but apply to audio signal. This avoid to have a messy patch with lot of connections.

Then we adapt each waveform generators to apply the frequency modulation. We name it “FM” for “Frequency Modultation”, we’ll add later more effect on frequency using this named signal as the final frequency modultation. Note that generators like noise doesn’t have base frequency. Here is an example of how we apply it to the “sin” waveform, it’s the same principle for all other waveforms.

You can download the main modified patch.

Let’s move to a huge effect which simulate low-fi / old 8-bit games.

Then we just apply this effect as the last stage of our audio chain :

download

Since we need the sound trigger message, we have a ugly wire traversing the whole patch. It’s time to cleanup a little. In PD you always have 2 ways to connect objects with message flows. Both approach have pros and cons :

There is no drawback in term of performence it’s just a choice of design : In our patch, the “trigger” event is already used in a lot of places and will be used in many placed as we implements new effects so it’s a good choice to use send/receive instead of wires. Here is the result :

download

OK we already have something valuable, it produce interesting sounds and maybe we already want to use them in our games or any other apps. So let’s implements a wavefile export.

PD provides all you need to import/export raw PCM audio files like WAV and AIFF from/to arrays and system file browser feature. We already have a array/table to display our sound so we could use it but to export a well cuted audio we’ll need to resize array depending of audio length. The length of the generated audio depends on the amplitude envelop : it’s the sum of attack, sustain and decay durations, so let’s compute it and send it from our ASD envelop :

We already have a table storing our sound, we will resize it to the total duration which fix a bug we had so far : the wave preview wasn’t resizing to the sound length.

Now we can use the duration message to resize our table before start recording when sound is triggered. This is the right part of our subpatch.

At the left, it’s the save flow :

Finally, we just add a button in the main patch :

And the wave file in audacity :

You can download the whole patch.

One cool feature in BFXR is preset randomization. It allow to randomize all or a part of parameters. You may noticed a toggle button for each controls we added, this is the lock feature. When you randomize the current preset, you may want to not randomize all of them, just enable the toggle and the parameter won’t be touched.

The implementation is part of control abstraction and explain in appendix. We just add the randomize button (which send a global “randomize” message) and trigger the sound as well when we randomize the preset to hear the result instantaneously.

download

Export to a wave file is nice but we want to save control settings as well to reload then later and organize a preset library for futur use.

I present here features, as said before this is an advanced feature explained in appendix.

The abstraction is called “presets” and like control abstraction you need to have the file in the patch folder, you can download it here.

here is how it is integrated in our main patch :

download

Here is what we get in file :

This work as expected but something missing : the selected waveform. The reason is didn’t use a control abstraction but a simple selector. Let’s replace it with a “select-control” abstraction which is close to control but using a selector instead of a slider.

like control abstraction you need to have the file in the patch folder, you can download it here.

You can download the fixed patch here. Note that we defined a range of 5 in order to randomizer to choose between waveform we implemented so far.

We can then create some predefined preset like BFXR does. Some presets are provided in the final application. TODO : add some preset in it (like pfxr …)

OK enough with technical feature, we’re to make some sounds, so let’s back to our audio core flow and implements other effects.

The pitch jump feature in BFXR is actually a kind of arpegiator or sequencer applying to the pitch. So it’s just 2 square signal with independant range and frequency added to waveform pitch. Each range from +/- one octavia (half to twice original frequency) so we need to convert.

Pitch jumping will modulate frequency like vibrato we seen before. We’ll rename the old “vibrato” subpatch to “pitch” and implement into it : sum-up these modulations.

We’ll take some liberty here from BFXR implementation to achieve more variations :

download

Here is few improvement made for the final patch :

you can download the final application as zip file here

Obviously we didn’t implements all the FX you can found in BFXR/SFXR but we have something usable and you can improve it on your own now including :

Thanks for reading.

appendix will be covered soon.

We cover here the control abstraction we used so far. It imply lot of pd knowlegements : how GUI element work, messaging, … etc.

TODO explain

A nice feature in BFXR is the autoplay when value change. Lets implement it with PD. We will send a global message when a control value change as well.

TODO explain here advanced PD use : control name binding, graph on parent … etc

There is several ways to save audio in pd. For this patch we’ll just record the sound based on the band event and duration auto set to sample length (total envelop).

[1]
Edit
Query
Report
Connor Cer
Telephone Maintainer
Answer # 3 #

You can run Bxfr straight from the website, or download a standalone version for Windows or Mac. It looks like this:

That's... a lot of buttons and controls. It looks overwhelming, but don't worry; you don't need to understand what they all do to get started.

First, concentrate on the top seven buttons on the left: Pickup/Coin, Laser/Shoot, Explosion, Powerup, Hit/Hurt, Jump, and Blip/Select. Click any, and it will generate a sound effect that fits the category.

When you find something you like, you can click Mutation to alter it a little bit. (Randomize, by contrast, will just give you a brand new, random effect.)

If you kept Create New Sound ticked, then you'll now have a bunch of effects in the bottom-left list. You can click any to play it again, and then type to rename it or click the X button to remove it.

The buttons at the bottom right let you share, save, and load your sound effects. When you've got something you like, you can hit Export Wav to save it as a wav file, which you should be able to use directly in any game engine (or at least convert to another format that can be used, like MP3 or OGG).

Alternatively, you can hit Save to Disk to export a bfxrsound file, which looks like this:

This is the same format used by the Copy and Paste buttons - try copying that above string into Bfxr and you'll see what I mean. Alternatively, you can use the Copy Link button, which gives you a link like this that encodes the bfxrsound data and automatically passes it to the tool.

The central panel gives you a whole heap of options. Let's look at a few:

Every slider and button has tooltip text explaining what it does - although in many cases it might be easier just to fiddle around with the value and listen to how it changes the sound! As you do so, you can overwrite your current effect with the Apply Synth button, or go back to how the effect initially sounded with the Revert Synth button.

The lock icon to the side of each control lets you state that you don't want it to be affected by the Randomize or Mutation buttons. You could, for example, lock everything except the Attack Time, Sustain Time, and Decay Time sliders and repeatedly hit Randomize to get a range of effects that sound similar but last different lengths of time.

Finally, the Mixer tab lets you overlap up to five of the effects you've made.

Bfxr, by Stephen Lavelle, is based on Tom Vian's as3sfxr, which in turn is an AS3 port of Tomas Pettersson's sfxr.

Sfxr and as3sfxr have fewer features, as the screenshot above shows, but that does make them a little less overwhelming. There's also a Mac version, cfxr, and a JavaScript version, jsfx.

Tom Vian gave a presentation on as3sfxr at the Flash on the Beach conference (since renamed to Reasons to be Creative):

As well as giving a fantastic overview of what all the sliders do, he also mentions the SfxrSynth AS3 class, which lets you import as3sfxr effect data into a Flash game's code and even mutate it on the fly. Bfxr offers the same functionality - see this API example for some sample code. Zeh Fernando has also ported this synthesiser to Unity.

Finally, I recommend checking out Mark Wonnacott's IECSFXR - Three new ways to use sfxr, which offer new interfaces for as3sfxr:

[1]
Edit
Query
Report
Imre Naz
CADDIE