Home > Audio/Video Circuits >Audio Processing > Tutorial on making a MIDI arpeggio synthesizer

Tutorial on making a MIDI arpeggio synthesizer

Source: InternetPublisher:明天见 Keywords: Synthesizer Chip MIDI Updated: 2024/12/27

With this project you can turn your CHIP into a simple synthesizer that is ready to use, capable of creating a wide variety of sounds. Control it with a MIDI keyboard or even OSC!

As a long-time electronic music lover and enthusiast, I can see any piece of technology as a source of sound. Since the chip has built-in audio, battery operation, and a convenient USB jack, I knew it would make a great little portable interactive noise box with a variety of great sounds.

The first step in implementing CHIP-MAS was to find a good platform for programming synthesizers. There are several different paths to choose from: C++ and an audio framework like asoundlib or Jamoma, python and Pyo, a professional language like Faust, or, if you want to do something simple with samples, Pygame or Pysound. I chose Pure Data (aka Pd), an open source, extensible graphical programming environment. Designed to generate and manipulate sounds, Pure Data is a great way to quickly prototype and create new ways of making music.

Once I decided on a programming environment, it was time to develop the synthesizer. I used one of the more interesting but less CPU-intensive examples from the Pure Data samples ( C08.analog.sequencer.pd ) as it has an interesting wavetable synthesizer and a sequencer. I did a lot of work to give the synthesizer more sonic diversity and integrated a MIDI keyboard to create arpeggiated sequences.

Overview

The basic steps are

Startup Chip

Install Pure Data

Get Git (repo)

Set the synthesizer to start at boot time

Install Pure Data

The first step is to install the Pure Data program. Pure Data comes in "extended" and "vanilla" versions. As you might expect, "extended" provides more features, but I didn't need those extra features, so I installed "vanilla." Installation is easy from the command line on the CHIP:

sudo apt-get update

s

Humans are very sensitive listeners. One of the challenges of music programming is to keep the time from "performing an action" (pressing a key on the piano keyboard) to "hearing the sound" as short as possible. This is generally called "latency" and is a huge topic of compromise for electronic music producers and programmers.

Pure Data prefers to give high priority to the operating system, and this can be done with some configuration. Edit the configuration file in the nano editor:

sudo nano /etc/security/limits.conf

Add the line where:

@audio - rtprio 99

@audio - memlock unlimited

to the end of the file. Now you can restart CHIP to make sure it takes effect

sudo reboot

In order for this stuff to actually work, Pure Data needs to be started from a CHIP terminal with the "live" flag on, like this:

pd-rt

If you want to make your own synthesizers or modify the ones I made, you might also want to install the Pure Data application on your "everyday" computer. The CHIP is a great computer, but if you have a faster computer with a higher resolution monitor, you might find it easier to program with Pure Data, as it tends to take up a lot of screen space.

Get a software synthesizer

Go to your Documents folder, and extract the git repo:

cd ~/Documents

git clone https://github.com/nyboer/CHIPMAS.git

Some synth details

If you're interested in how synthesizers work, here are a few things worth mentioning. When making the synthesizer, I wanted to be able to create a wide variety of sounds: percussive, noisy, bright, simple, clean, aggressive, and so on. However, I didn't want to use up too much CPU. So I chose a wavetable synthesizer design, which can scan tables of different sizes to produce several complex waveforms from a single wave. After that I created a few tables that can be mixed, resulting in a lot of possible timbres. Add synchronized low-pass filters, amplitude and table scan envelopes, and we have a very versatile synthesizer.

pYYBAGMN086AX17HAAIAM5nrHKU062.png

All parameters can be controlled via Open Sound Control (OSC), which means this tiny synth is network-capable. But for this simple case, I designed it around a cheap Akai Synth Station 25 keyboard. This way, I can plug in a USB MIDI controller, fire up CHIP, and have a complex synth sound.

You'll notice that the jump git repository below this article also has a file called "graintable.touchosc", which is the file for the Touch OSC app for Android and iOS. It gives you control over multiple parameters in CHIP-MAS, as well as the option to control the sound using your phone's motion sensors.

Connecting the controller

poYBAGMN09SATvTeAAIg2kGlR_4367.png

I designed this piece with a MIDI keyboard. You just press a chord and the notes play in the order you press the keys. Use the modulation and pitch bend wheels to change the filter cutoff frequency and the crossfades between wavetables. If you use an Akai Synth Station 25 keyboard, you can use six of the eight buttons to change presets (the top row of buttons) or change the tempo (up or down, in 4 BPM increments).

Before starting CHIP, you need to connect your keyboard so that the program can find it.

Make a sound

Just press keys on your keyboard and move the pitch and modulation wheels to make some weird sounds.

Final product

pYYBAGMN09mAVhvjAAMboJG_Gc0016.png

Eventually, I'd like to turn this into a fully functional project that can be used in a series of steps: plug in a keyboard, turn on the chip, plug in headphones, and quit.

This is pretty easy to do though, the necessary service files are included in the git repository. The service script simply tells Linux to turn on our compositor patch once a certain service is available. You should double check the line: systemd

ExecStart=/usr/bin/pd -nogui -rt /home/chip/Documents/CHIPMAS/CHIPMASsynth.pd

Make sure the absolute paths to pd and CHIP-MASsynth.pd are correct.

Change your directory to wherever you have your git repository, and then copy the services file from the repository to the correct location:

sudo cp chipmassynth.service /etc/systemd/system/chipmassynth.service

Now we need to make our systemd aware of this new service:

sudo systemctl daemon-reload

sudo systemctl enable chipmassynth.service

You can test the service with the following command:

sudo systemctl start chipmassynth

and

systemctl status chipmassynth

and

sudo systemctl stop chipmassynth

The Pure Data patch has some special information in the "pd init" subpatch to make sure it grabs the first MIDI device, turns off the audio input, and turns on the first audio input (the CHIP's built-in audio) to ensure the synth chip is ready to play once it boots up.

Make CHIP unique

CHIP has "zero configuration networking" enabled via `avahi`, but I want to take full advantage of this. I have several CHIPs lying around, so it would be better if they had unique names.

In short, you need to edit a couple of files and change "chip" to "synth" (or whatever you want to call it)

sudo nano /etc/hostname

sudo nano /etc/hosts

Also, I'm on a Mac, so I like to add Apple Services:

sudo nano /etc/avahi/services/afpd.service

And add the following:

Restart avah:

sudo /etc/init.d/avahi-daemon restart

Password-free login

It would also be nice to be able to use `ssh` and `scp` to control and copy files to CHIP without having to enter a password every time.

Generate an SSH key pair on your computer

ssh-keygen -t rsa

and save it to

~/.ssh/id_rsa.pub

Copy it to CHIP:

scp ~/.ssh/id_rsa.pub chip@:~/

On CHIP, you need to install rsync, set it up for ssh, and copy your public key into its authorized keys file:

cd ~/

sudo apt-get install rsync

mkdir .ssh

cat id_rsa.pub 》》 .ssh/authorized_keys

rm id_rsa.pub

chmod go-w ~

chmod 700 ~/.ssh

chmod 600 ~/.ssh/authorized_keys

Now, on your host, you can easily move all PureData patches without logging in:

rsync -avzu CHIPMAS/ chip@boer04.local:~/Documents/CHIPMAS

Possible extensions

I'm glad I finished a simple synthesizer on CHIP for such a cheap price Even though I set out to build something very simple, there's actually quite a bit of signal calculation going on in this synthesizer, since it's scanning 4 wavetables simultaneously and mixing them along with the noise signal, modulating them with an envelope.

Even though it's not optimized it still only takes about 25% of the cpu of CHIP. I think the synth could be simplified and fixed to turn off things that aren't being used. It could also use some oversampling to improve the sound quality, and the more CPU intensive but better sounding Moog analog "bob~" filter could be removed in place of Pure Data's "vcf~".

Finally, you need to take advantage of the CHIP's built-in networking. CHIPs are so cheap that it's not unreasonable to run 6 or 8 of these synthesizers on a single CHIP and synchronize and control them over the network.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号