Skip to main content

Lesson 9 - First interaction with frequency modulation

Completion requirements
Setup a basic interactive scenario, using data sent over TouchOSC to control the frequency modulation patch with a smart device. Data smoothing, mapping and scaling.

Lesson 9:

edu sharing object


Transcript

00:07 - Lesson 09. First interaction with frequency modulation. In this tutorial we are going to set up a basic interactive scenario, and you will also become familiar with two new abstractions. You already know the “abstraction oscListener” that is necessary to receive the data we saw previously. These data are not ready yet to be used and we need to apply some treatment to them. What am I talking about? First of all the data we get is not extremely precise; it might contain some incongruent values due to the fast rate at which they came in. Incongruent values take the name of “noise”, and the best strategy to get rid of the “noise” in the data flow is to filter it out. Although there are several strategies for filtering data, using biquadratic lowpass filtering has been proven to be among the most effective. Let’s create a new object and write inside “ abs underscore filter”. 01:10 - This is the filter I mentioned and which I already implemented for you. How does it work? It’s not necessary at this point to understand the math under the hood, but if you are curious, you can click on the object and explore its content. 01:27 - What you need to know is that the left inlet takes the data to be filtered. The right one accepts a number in the range of 0 to 1. What is it for? We could say that this range roughly represents the amount of data to be passed. If it is set to 0 no data will pass, if set to 1 it will be as if you were not using the filter at all, because all the data would pass through. For the moment we don’t need to assign a number because I already set it to pass half of the data, so 0.5 as default. 02:06 - Let’s now connect the first outlet of the “oscListener”, which sends out the values relative to acceleration on the x axis, to the inlet of the filter “abstraction”. 02:18 - Repeat now the operation for the y and z axes like this. 02:03 - We still need one more abstraction before our data can be used. The data we are looking at has a range that usually goes from -2 to +2. This range might change according to the company that has produced the device and it could also be bigger, for example -4. +4, but let’s now stick with a narrow range which will allow us a pretty fine control. The problem is that the synthesis parameters we would like to control usually have a different range. In other words we need to scale these values. So create a new object and type inside “abs underscore scale”. 03:24 - You also have to connect four “numberboxes” to the scale abstraction starting from the second inlet. 03:59 -Through these “numberboxes" we can set the scale parameters: the present range -2 +2, as we said, in the first two “numberboxes”. And the range we want to scale these values to, but for the moment we leave those blank, because we don’t know the range yet. 04:19 - Let’s repeat the operation for y and z axes. 04:53 - And also set the incoming range, which is the same for all 3 axes. 05:03 - We are almost ready. Now it is time to take some creative decisions because we have to decide which values will control different parameters of the “FM” synthesis. In other words we have to “map” incoming values to synthesis parameters. There are no strict rules to do the mapping at this stage. The only rule, let’s say, is that the mapping, in order to be effective, should reflect in the sonic result the movement of your hand in an understandable and meaningful way. 05:35 - You are not only free, but you should also try different mapping settings. Now I will show you one possible mapping. Each horizontal movement along the x axis controls the “carrier” frequency. Before connecting the outlet of the scale abstraction, we have to set a range for the “carrier” to move inside. I would suggest 50 to 1,000 Hz. Values below 50 Hz are hardly audible unless you use dedicated speakers; values over 1,000 Hz might produce harsh results. Don’t forget this is only a suggestion; I encourage you to try several different ranges according to the results you would like to hear. Let’s connect the outlet of the scale object, turn the “oscListener” on and we can already see the “carrier” frequency changing. 06:33 - Let’s make a first test by turning audio on, increasing the volume and setting some random numbers for the other parameters only to listen to the result. 06:57 - As you see, when I make a horizontal acceleration the “carrier” will increase and vice versa. 07:05 - Excellent! Let’s now turn the audio off again. 07:14 - Each vertical movement, along the y axis, controls the “modulator”. The range I set here is narrower, let’s say 50 to 200 hz should be fine, and connect it. 07:42 - Each movement along the z axis will control the volume. Here as you know the range of volume is 0 to 1, and connect it. 07:54 - We still have to map the centre frequency of the filter, so for the moment let’s just centre it around 500 Hz. And the modulation depth, we could manually set it around 100, or any other positive number you like. 08:12 - I will show you in a minute how to map these latter two values, because we already used all three values coming from the accelerometer. Let’s turn the audio on again and start to play our little synthesizer by moving the smartphone. 08:40 - Wow, as you can hear it is not only really responsive to our gestures, but we also get quite interesting results. Let’s turn the audio off again to make the last two mappings. 08:56 - Let’s now use some more features of TouchOSC. The default layout is the one named “Simple” and it should look like this. 09:06 - If it is not the one you are looking at now, just go back, press in the corner and under layout select “Simple”. Here we go. 09:23 - Also the values coming from these “sliders” or “faders” and even the “toggles” can be retrieved inside Pure Data. The values of the “sliders” are in the range from 0 to 1, and the values of the first slider actually come out of the fourth outlet, the second from the fifth and so on. The eighth outlet sends out the values of the horizontal slider, while the next outlet, the ninth, sends the value of the first toggle here: 0 or 1. Let’s now use the first slider to control the modulation intensity. We don’t have to filter values coming from TouchOSC GUI because they are not continuous, and actually to scale these incoming values we just need to multiply them, let’s say by 10,000 to achieve a great variety in resulting sounds. 10:27 - We could then use the horizontal slider to control the centre frequency of the filter. Also in this case we don’t need the scale abstraction because we can set an upper limit for the centre frequency just by multiplying like this. 11:07 - We then add an offset, for example 100, because otherwise the lowest limit of the centre frequency would be 0 and this wouldn’t make sense because we wouldn’t hear anything. 11:21 - Great! we are now fully ready to start playing with our synthesizer and explore its sonic possibilities.



Example Patch:

 

edu sharing object
 

 

edu sharing object
 

 

edu sharing object
 

Last modified: Tuesday, 12 September 2023, 6:35 PM