Skip to content

Commit

Permalink
Support Raspberry Pi 5
Browse files Browse the repository at this point in the history
With USB streaming devices only
  • Loading branch information
rsta2 committed Feb 28, 2024
1 parent da62652 commit 0b72f48
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
MiniSynth Pi
============

> Raspberry Pi is a trademark of Raspberry Pi Trading.
> Raspberry Pi is a trademark of Raspberry Pi Ltd.
> If you read this file in an editor you should switch line wrapping on.
Overview
--------

MiniSynth Pi is a polyphonic virtual analog audio synthesizer, running bare metal (without separate operating system) on the Raspberry Pi. On the Raspberry Pi 2, 3 and 4 it allows to play up to 24 polyphonic voices at a time, on the Raspberry Pi 1 only 4 voices.
MiniSynth Pi is a polyphonic virtual analog audio synthesizer, running bare metal (without separate operating system) on the Raspberry Pi. On the Raspberry Pi 2, 3, 4 and 5 it allows to play up to 24 polyphonic voices at a time, on the Raspberry Pi 1 only 4 voices.

You have to attach an USB MIDI keyboard controller (which supports the USB Audio Class MIDI specification) or an USB PC keyboard to your Raspberry Pi to play on it. Alternatively you can feed serial MIDI data (at 31250 Bps) into GPIO15 (Broadcom numbering). Normally you will need some external circuit to be able to attach a device with serial MIDI interface.

Expand All @@ -24,7 +24,7 @@ This version of MiniSynth Pi can be configured, so that it can be used with an e

Other I2S interfaces with these DACs may be compatible too. The I2C slave address of the DAC is auto-probed (0x4C, 0x4D or 0x1A).

On the Raspberry Pi 4 and 400 also external USB sound cards can be used.
On the Raspberry Pi 4 and 400 also external USB sound cards can be used. USB sound cards are the only supported option on the Raspberry Pi 5.

Please note that the included reverb effect module is experimental, because it generates some noise, when no note is played. Just leave the reverb volume (wet/dry ratio) at 0% to eliminate it, if it disturbs.

Expand Down Expand Up @@ -55,11 +55,11 @@ When the toolchain is installed on your computer you can build MiniSynth Pi usin
./makeall clean
./makeall

The `configure` command writes a *Config.mk* file for Circle and patches Circle, so that it allows to use multiple CPU cores. "3" is the major revision number of your Raspberry Pi (1, 2, 3 or 4). The second (optional) parameter is the prefix of the commands of your toolchain and can be preceded with a path. Do not forget the dash at the end of the prefix!
The `configure` command writes a *Config.mk* file for Circle and patches Circle, so that it allows to use multiple CPU cores. "3" is the major revision number of your Raspberry Pi (1, 2, 3, 4 or 5). The second (optional) parameter is the prefix of the commands of your toolchain and can be preceded with a path. Do not forget the dash at the end of the prefix!

An optional third parameter can be appended to specify the bit size of the ARM architecture to be used as build target. It can be "32" (default) or "64" (for Raspberry Pi 3 and 4 only).
An optional third parameter can be appended to specify the bit size of the ARM architecture to be used as build target. It can be "32" (default) or "64" (for Raspberry Pi 3 and 4 only). For the Raspberry Pi 5 it must be "64" (default).

If the build was successful, you find the executable image file of MiniSynth Pi in the *src/* subdirectory with the name *kernel.img* (Raspberry Pi 1), *kernel7.img* (Raspberry Pi 2), *kernel8-32.img* (Raspberry Pi 3) or *kernel7l.img* (Raspberry Pi 4).
If the build was successful, you find the executable image file of MiniSynth Pi in the *src/* subdirectory with the name *kernel.img* (Raspberry Pi 1), *kernel7.img* (Raspberry Pi 2), *kernel8-32.img* (Raspberry Pi 3), *kernel7l.img* (Raspberry Pi 4) or *kernel_2712.img* (Raspberry Pi 5).

Installation
------------
Expand All @@ -71,15 +71,15 @@ Furthermore you need the Raspberry Pi firmware. You can get it as follows:
cd circle/boot
make

You have to copy the three files *bootcode.bin*, *start.elf* and *fixup.dat* from the *circle/boot/* subdirectory to the FAT partition on the SD card. The Raspberry Pi 4 requires different firmware files. Please read the file *circle/boot/README* for details!
You have to copy the three files *bootcode.bin*, *start.elf* and *fixup.dat* from the *circle/boot/* subdirectory to the FAT partition on the SD card. The Raspberry Pi 4 and 5 require different firmware files. Please read the file *circle/boot/README* for details!

Finally you have to copy the configuration files *cmdline.txt*, *patchN.txt* (example patches), *velocity-???.txt* (keyboard velocity curve) and *midi-cc.txt* (MIDI CC mapping) from the *config/* subdirectory to the SD card. The appropriate velocity curve file has to be renamed to *velocity.txt* to be used. You can optionally create a subdirectory */patches* and copy the example patches there, if you do not want to have them in the root directory of your SD card.

If you want to use an I2S interface, you have to modify to file *cmdline.txt* on the SD card, so that it contains the following option (default is `sndpwm`):

sounddev=sndi2s

If you want to use an USB sound card (on the Raspberry Pi 4 and 400 only), you have to attach it, before the system is started. The file *cmdline.txt* must contain the following options, where `soundopt=` specifies the width of one audio sample in number of bits, and must be `24` for some (especially Pro) devices:
If you want to use an USB sound card (on the Raspberry Pi 4, 400 and 5 only), you have to attach it, before the system is started. The file *cmdline.txt* must contain the following options, where `soundopt=` specifies the width of one audio sample in number of bits, and must be `24` for some (especially Pro) devices:

sounddev=sndusb soundopt=16

Expand Down
8 changes: 6 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
if [[ $# != 1 && $# != 2 && $# != 3 ]] ; then
echo "Usage: $0 rasppi [ prefix [ aarch ] ]"
echo
echo "rasppi Major revision number of the Raspberry Pi to build for (1, 2, 3 or 4)"
echo "rasppi Major revision number of the Raspberry Pi to build for (1, 2, 3, 4 or 5)"
echo "prefix Path and prefix of the toolchain commands (e.g. /path/arm-eabi-)"
echo "aarch Bit size of ARM architecture (32 or 64, default 32)"

exit
fi

if [[ $1 != "1" && $1 != "2" && $1 != "3" && $1 != "4" ]] ; then
if [[ $1 != "1" && $1 != "2" && $1 != "3" && $1 != "4" && $1 != "5" ]] ; then
echo "Invalid revision number ($1)"

exit
Expand All @@ -32,6 +32,10 @@ fi
aarch=32
if [[ $# == 3 ]] ; then
aarch=$3
else
if [[ $1 == "5" ]] ; then
aarch=64
fi
fi

if [[ $aarch != "32" && $aarch != "64" ]] ; then
Expand Down
6 changes: 5 additions & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// kernel.cpp
//
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi
// Copyright (C) 2017-2022 R. Stange <[email protected]>
// Copyright (C) 2017-2024 R. Stange <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -111,6 +111,7 @@ boolean CKernel::Initialize (void)

if (bOK)
{
#if RASPPI <= 4
const char *pSoundDevice = m_Options.GetSoundDevice ();
assert (pSoundDevice);
if (strcmp (pSoundDevice, "sndi2s") == 0)
Expand All @@ -128,6 +129,9 @@ boolean CKernel::Initialize (void)
{
m_pSynthesizer = new CMiniSynthesizerPWM (&m_Config, &m_Interrupt);
}
#else
m_pSynthesizer = new CMiniSynthesizerUSB (&m_Config, &m_Interrupt);
#endif

assert (m_pSynthesizer);
bOK = m_pSynthesizer->Initialize ();
Expand Down
10 changes: 9 additions & 1 deletion src/minisynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// minisynth.cpp
//
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi
// Copyright (C) 2017-2023 R. Stange <[email protected]>
// Copyright (C) 2017-2024 R. Stange <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -185,6 +185,8 @@ void CMiniSynthesizer::GlobalUnlock (void)

//// PWM //////////////////////////////////////////////////////////////////////

#if RASPPI <= 4

CMiniSynthesizerPWM::CMiniSynthesizerPWM (CSynthConfig *pConfig,
CInterruptSystem *pInterrupt)
: CMiniSynthesizer (pConfig, pInterrupt),
Expand Down Expand Up @@ -269,8 +271,12 @@ unsigned CMiniSynthesizerPWM::GetChunk (u32 *pBuffer, unsigned nChunkSize)
return nResult;
}

#endif

//// I2S //////////////////////////////////////////////////////////////////////

#if RASPPI <= 4

CMiniSynthesizerI2S::CMiniSynthesizerI2S (CSynthConfig *pConfig,
CInterruptSystem *pInterrupt,
CI2CMaster *pI2CMaster)
Expand Down Expand Up @@ -356,6 +362,8 @@ unsigned CMiniSynthesizerI2S::GetChunk (u32 *pBuffer, unsigned nChunkSize)
return nResult;
}

#endif

//// USB //////////////////////////////////////////////////////////////////////

#if RASPPI >= 4
Expand Down
10 changes: 9 additions & 1 deletion src/minisynth.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// minisynth.h
//
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi
// Copyright (C) 2017-2023 R. Stange <[email protected]>
// Copyright (C) 2017-2024 R. Stange <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -98,6 +98,8 @@ class CMiniSynthesizer

//// PWM //////////////////////////////////////////////////////////////////////

#if RASPPI <= 4

class CMiniSynthesizerPWM : public CMiniSynthesizer, public CPWMSoundBaseDevice
{
public:
Expand All @@ -115,8 +117,12 @@ class CMiniSynthesizerPWM : public CMiniSynthesizer, public CPWMSoundBaseDevice
boolean m_bChannelsSwapped;
};

#endif

//// I2S //////////////////////////////////////////////////////////////////////

#if RASPPI <= 4

class CMiniSynthesizerI2S : public CMiniSynthesizer, public CI2SSoundBaseDevice
{
public:
Expand All @@ -135,6 +141,8 @@ class CMiniSynthesizerI2S : public CMiniSynthesizer, public CI2SSoundBaseDevice
boolean m_bChannelsSwapped;
};

#endif

//// USB //////////////////////////////////////////////////////////////////////

#if RASPPI >= 4
Expand Down
6 changes: 3 additions & 3 deletions src/serialmididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// serialmididevice.cpp
//
// MiniSynth Pi - A virtual analogue synthesizer for Raspberry Pi
// Copyright (C) 2017-2022 R. Stange <[email protected]>
// Copyright (C) 2017-2024 R. Stange <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -25,9 +25,9 @@ CSerialMIDIDevice::CSerialMIDIDevice (CMiniSynthesizer *pSynthesizer, CInterrupt
CSynthConfig *pConfig)
: CMIDIDevice (pSynthesizer, pConfig),
#if RASPPI <= 3 && defined (USE_USB_FIQ)
m_Serial (pInterrupt, FALSE),
m_Serial (pInterrupt, FALSE, 0),
#else
m_Serial (pInterrupt, TRUE),
m_Serial (pInterrupt, TRUE, 0),
#endif
m_nSerialState (0)
{
Expand Down

0 comments on commit 0b72f48

Please sign in to comment.