Showing posts with label sn76489. Show all posts
Showing posts with label sn76489. Show all posts

Monday, June 01, 2020

SN76489 USB

I wanted to make a slightly more modern implementation of my SN76489 USB. The main changes are: Teensy LC, 3.2, 3.6 compatibility, and no need for an external crystal oscillator as the Teensy generates a 3MHz signal for the timing of the SN76489.

The hardware connection is as follows:

  • Pin 0 to SN76489 write enable 
  • Pin 3 to SN76489 clock input
  • Pin 4 - 11 to SN76489 D0 to D7
  • Teensy 5V to SN76489 5V
  • Teensy ground to SN76489 ground and output enable





Download the code from here: https://github.com/little-scale/arduino-sketches/blob/master/sn76489_USB.ino


Monday, January 01, 2018

Oct SN76489 MIDI Array




The SN76489 is the same sound chip as found in the SEGA Master System. This is an array of eight SN76489 sound chips playable via USB MIDI, for a total of 32 hardware channels.



MIDI channels 1 - 16 are each split, so that each channel can represent two hardware channels. This is achieved by splitting the MIDI pitch range across two SN76489 channels. A C3 played on MIDI channel 1 with a transposition of -36 semitones will sound like a C3 being played on SN76489 chip 1, channel 1. A C3 played on MIDI channel 1 with a transposition of +24 semitones will sound like a C3 being played on SN76489 chip 1, channel 2. 

Thus, the 16 MIDI channels are mapped as follows: 
SN76489 Chip 1, Channel 1: MIDI Channel 1 -36 semitones
SN76489 Chip 1, Channel 2: MIDI Channel 1 +24 semitones
SN76489 Chip 1, Channel 3: MIDI Channel 2 -36 semitones
SN76489 Chip 1, Channel 4: MIDI Channel 2 +24 semitones
SN76489 Chip 2, Channel 1: MIDI Channel 3 -36 semitones
SN76489 Chip 2, Channel 2: MIDI Channel 3 +24 semitones
SN76489 Chip 2, Channel 3: MIDI Channel 4 -36 semitones
SN76489 Chip 2, Channel 4: MIDI Channel 4 +24 semitones
SN76489 Chip 3, Channel 1: MIDI Channel 5 -36 semitones
SN76489 Chip 3, Channel 2: MIDI Channel 5 +24 semitones
SN76489 Chip 3, Channel 3: MIDI Channel 6 -36 semitones
SN76489 Chip 3, Channel 4: MIDI Channel 6 +24 semitones
SN76489 Chip 4, Channel 1: MIDI Channel 7 -36 semitones
SN76489 Chip 4, Channel 2: MIDI Channel 7 +24 semitones
SN76489 Chip 4, Channel 3: MIDI Channel 8 -36 semitones
SN76489 Chip 4, Channel 4: MIDI Channel 8 +24 semitones
SN76489 Chip 5, Channel 1: MIDI Channel 9 -36 semitones
SN76489 Chip 5, Channel 2: MIDI Channel 9 +24 semitones
SN76489 Chip 5, Channel 3: MIDI Channel 10 -36 semitones
SN76489 Chip 5, Channel 4: MIDI Channel 10 +24 semitones
SN76489 Chip 6, Channel 1: MIDI Channel 11 -36 semitones
SN76489 Chip 6, Channel 2: MIDI Channel 11 +24 semitones
SN76489 Chip 6, Channel 3: MIDI Channel 12 -36 semitones
SN76489 Chip 6, Channel 4: MIDI Channel 12 +24 semitones
SN76489 Chip 7, Channel 1: MIDI Channel 13 -36 semitones
SN76489 Chip 7, Channel 2: MIDI Channel 13 +24 semitones
SN76489 Chip 7, Channel 3: MIDI Channel 14 -36 semitones
SN76489 Chip 7, Channel 4: MIDI Channel 14 +24 semitones
SN76489 Chip 8, Channel 1: MIDI Channel 15 -36 semitones
SN76489 Chip 8, Channel 2: MIDI Channel 15 +24 semitones
SN76489 Chip 8, Channel 3: MIDI Channel 16 -36 semitones
SN76489 Chip 8, Channel 4: MIDI Channel 16 +24 semitones



The hardware setup has one Teensy LC, with a common data bus (digital pins 0 - 7) and individual chip select (digital pins 8 - 15). One external 4 MHz crystal provides the timing for all eight SN76489.



Sunday, November 17, 2013

Chiptune Array: 128 Hardware Channels

A critical mass of simple things, combined. 



An array of sound chips, yielding 128 channels of chiptune hardware:
• 32 SN76489 sound chips addressable via 8 USB MIDI connections
• Uses the quad flavour of the SN76489 USB MIDI synth
• 96 square wave channels and 32 noise channels
• 8 audio channels
• Each audio channel carries the summed analog output of 4 SN76489 sound chips (or 16 voices / sound chip channels)
• Every channel of every SN76489 sound chip is controllable via MIDI, and includes sample playback via amplitude modulation, noise channel control, pitch bend and velocity control

 Currently, every SN76489 chip is clocked at 1.8432 MHz. I would like to experiment with different clocks for different chips, giving a wider pitch range over all. Currently, every group of 4 SN76489 chips is summed and then digitised via a Focusrite ADAT preamp and RME interface. I would like to (possibly) carry each audio channel from every SN76489 as a discrete digital input, however this may be stretching my resources. I am also working on a set of tools that are designed to help generate MIDI data en masse for such a setup. Stay tuned!

I am loving how thick and overflowing 96 square waves sound...





Sunday, May 26, 2013

SN76489 USB MIDI 103 Firmware: Quad Support!

Overview
SN76489 USB MIDI now supports up to four SN76489 chips per one Teensy! This means controlling up to 12 pulse wave channels and up to 4 noise channels using MIDI.

Additionally, sample support has been added for the first SN76489 chip and is handled by the first three pulse channels.



Mapping 
The 16 MIDI channels of the SN76489 USB MIDI are mapped to up to four SN76489 chips in the following way:






The sample playback of up to sixteen samples are mapped in the following way:

Note: Whenever a sample is playing, pulse channels 1, 2 and 3 of SN76489 chip 1 cannot be used.

The SN76489 USB will respond to:
• Note on events
• Note off events
• Pitch bend
• MIDI CC 11: expression
• MIDI CC 81: bend amount in semitones (default 12)





Parts, Pinouts and Circuit
Required:
• 1 x Teensy 2.0
• 1 - 4 x SN76489
• 1 x Crystal oscillator (1.00 MHz - 3.00 MHz, typically 1.8432 MHz)



Here are the pinouts for the Teensy 2.0, the SN76489 and the crystal oscillator.




Here is how these components should be connected. Download the spreadsheet here.





Here is an example breadboard layout for a single SN76489 chip:

Here is a picture of a breadboard layout for all four SN76489 chips:




Code

Download the code here. Please feel free to modify as you see fit, and have fun making chiptunes.

If you are having trouble triggering the notes in terms of matching up the channel numbers, please read this post.

Note that there is a line of code in the program that reads: long clock = 1843200; Simply change the value of clock in Hz to support any value of crystal oscillator whilst staying in tune!

The default is 1843200 (i.e. a clock speed of 1.8432 MHz) as this is the crystal speed that I prefer, however the SN76489 can accept a wide range of clock speeds. If you want a bassier pitch range, simply use a lower value crystal oscillator.

Three SN76489 Pulse Channels for Sample Playback

I have updated the code for how my SN76489 USB MIDI plays back samples.

Previously, I would use a single pulse channel and then trigger samples using the volume of that single pulse channel using amplitude sample data.

The aim of using only one pulse channel was that it would free up the other channels for melodic and harmonic use.

However, the result is that the sample playback is very, very soft in volume, meaning that there is more overall unwanted noise, and that there is also a limit to how the other channels can be used velocity-wise in order to balance out the single pulse channel that is used for sample playback.

I have decided to try out using all three pulse channels for sample playback, and all though this limits the use of all pulse channels on that particular SN76489 chip whenever sample data is playing.

The effective outcome is a much more balanced sample function in terms of volume. Samples also seem to sound 'crisper', less gain is needed to bring the chip up to appropriate levels.


Saturday, May 25, 2013

Piggybacked SN76489 Chips








One SN76489 is piggybacked on another. They share many pins and only a small number need to be isolated from each other.

• Removal of !READY pin
• Isolation of !WRITE_ENABLE pin
• Isolation of SOUND_OUT pin
• Shared data bus, ground and 5V pins

Quad SN76489 Prototype Demonstration


SN76489 USB MIDI Firmware 102: Linear Pitchbend, Clock-based Pitch

Overview
SN76489 USB MIDI Firmware 102 for the Teensy features the following changes:
• Pitchbend is musically linear, meaning that the same value pitch bend will give the same pitch distance no matter which pitch is played.

• CC71 on MIDI channels 1 - 4 sets the pitch bend range in semitones. The default is 12 semitones. 

• The frequency data for the SN76489 is calculated using a formula rather than a look up table.

• The advantage of this is there is a line of code in the program that reads: long clock = 1843200; Simply change the value of clock in Hz to support any value of crystal oscillator whilst staying in tune!

• The default is 1843200 (i.e. a clock speed of 1.8432 MHz) as this is the crystal speed that I prefer, however the SN76489 can accept a wide range of clock speeds. If you want a bassier pitch range, simply use a lower value crystal oscillator.


Download the firmware here: http://milkcrate.com.au/_other/downloads/teensy/SN76489_USB_MIDI_102/SN76489_USB_MIDI_102.ino



Example Breadboard Layout



Demonstration Video




Saturday, May 11, 2013

SN76489 Controlled By Samsung Galaxy S4

A demo of this process and this process.

Friday, May 10, 2013

SN76489 USB MIDI 101 Firmware for Arduino

The SN76489 Firmware has been ported to Arduino.

Note that a variable called "byte USB_SERIAL_MODE = 1;" sets whether or not data should be read from a traditional MIDI input or from a USB serial connection.

If USB_SERIAL_MODE = 1, then the mode is set to accept input from a USB serial connection. A traditional 5 pin MIDI connection will not work.

If USB_SERIAL_MODE = 0, then the mode is set to accept input from a traditional 5 pin MIDI connection. A USB serial connection will not work.

Download the firmware here: http://milkcrate.com.au/_other/downloads/teensy/SN76489_USB_MIDI_101/SN76489_USB_MIDI_101_ARDUINO.ino



==== DATA ====
Arduino PORTC 0 = Analog Pin 0 -->  SN76489 Pin 10 (Data 0)
Arduino PORTC 1 = Analog Pin 1 -->  SN76489 Pin 11 (Data 1)
Arduino PORTC 2 = Analog Pin 2 -->  SN76489 Pin 12 (Data 2)
Arduino PORTC 3 = Analog Pin 3 -->  SN76489 Pin 13 (Data 3)
Arduino PORTC 4 = Analog Pin 4 -->  SN76489 Pin 15 (Data 4)
Arduino PORTC 5 = Analog Pin 5 -->  SN76489 Pin 1 (Data 5)
Teensy PORTB 0 = Arduino Digital Pin 8 -->  SN76489 Pin 2 (Data 6)
Teensy PORTB 1 = Arduino Digital Pin 9 --> SN76489 Pin 3 (Data 7)

==== CONTROL AND MIDI INPUT ====
Arduino PORTD 2 = Arduino Digital Pin 2 --> SN76489 Pin 5 (Write Enable)
Arduino PORTD 0 = Arduino Digital Pin 0 / RX --> Receive data from MIDI INPUT CIRCUIT

==== POWER AND CRYSTAL ====
Teensy Ground --> SN76489 Pin 8 (ground)
Teensy Ground --> SN76489 Pin 6 (Output Enable)
Teensy Ground --> Xtal Osc Ground
Teensy 5V --> SN76489 Pin 16
Xtal Osc Signal --> SN76489 Pin 14 (Clock)

==== AUDIO OUTPUT ====
SN76489 Pin 7 --> Audio Output Signal
SN76489 Pin 8 --> Audio Output Ground

==== MIDI INPUT CIRCUIT (ONLY IF REQUIRED) ===
MIDI Input DIN 5 Pin 4 --> 4n28 Pin 1
MIDI Input DIN 5 Pin 5 --> 4n28 Pin 2
N4148 Diode (positive anode) --> 4n28 Pin 1
N4148 Diode (negative cathode) --> 4n28 Pin 2
4n28 Pin 6 --> 100k resistor (leg 1)
100k resistor (leg 2) --> Teensy Ground
4n28 Pin 5 --> Teensy PORTD 2 = Teensy Digital Pin 7
4n28 Pin 5 --> 3.3k resistor (leg 1)
3.3k resistor (leg 1) --> Teensy 5V
4n28 pin 4 --> Teensy Ground







Here are diagrams of the various devices.

SN76489 USB MIDI 101 Firmware

The SN76489 USB MIDI 101 firmware includes the following changes:
• Support for traditional 5 PIN DIN Plug via an optional MIDI input circuit



Download the firmware here: http://milkcrate.com.au/_other/downloads/teensy/SN76489_USB_MIDI_101/SN76489_USB_MIDI_101.ino




This firmware update changes the circuit of the Teensy and SN76489 as follows:

==== DATA ====
Teensy PORTB 0 = Teensy Digital Pin 0 -->  SN76489 Pin 10 (Data 0)
Teensy PORTB 1 = Teensy Digital Pin 1 -->  SN76489 Pin 11 (Data 1)
Teensy PORTB 2 = Teensy Digital Pin 2 -->  SN76489 Pin 12 (Data 2)
Teensy PORTB 3 = Teensy Digital Pin 3 -->  SN76489 Pin 13 (Data 3)
Teensy PORTB 4 = Teensy Digital Pin 13 -->  SN76489 Pin 15 (Data 4)
Teensy PORTB 5 = Teensy Digital Pin 14 -->  SN76489 Pin 1 (Data 5)
Teensy PORTB 6 = Teensy Digital Pin 15 -->  SN76489 Pin 2 (Data 6)
Teensy PORTB 7 = Teensy Digital Pin 4 --> SN76489 Pin 3 (Data 7)

==== CONTROL AND MIDI INPUT ====
Teensy PORTD 0 = Teensy Digital Pin 5 --> SN76489 Pin 5 (Write Enable)
Teensy PORTD 2 = Teensy Digital Pin 7 --> Receive data from MIDI INPUT CIRCUIT

==== POWER AND CRYSTAL ====
Teensy Ground --> SN76489 Pin 8 (ground)
Teensy Ground --> SN76489 Pin 6 (Output Enable)
Teensy Ground --> Xtal Osc Ground
Teensy 5V --> SN76489 Pin 16
Xtal Osc Signal --> SN76489 Pin 14 (Clock)

==== AUDIO OUTPUT ====
SN76489 Pin 7 --> Audio Output Signal
SN76489 Pin 8 --> Audio Output Ground

==== MIDI INPUT CIRCUIT (ONLY IF REQUIRED) ===
MIDI Input DIN 5 Pin 4 --> 4n28 Pin 1
MIDI Input DIN 5 Pin 5 --> 4n28 Pin 2
N4148 Diode (positive anode) --> 4n28 Pin 1
N4148 Diode (negative cathode) --> 4n28 Pin 2
4n28 Pin 6 --> 100k resistor (leg 1)
100k resistor (leg 2) --> Teensy Ground
4n28 Pin 5 --> Teensy PORTD 2 = Teensy Digital Pin 7
4n28 Pin 5 --> 3.3k resistor (leg 1)
3.3k resistor (leg 1) --> Teensy 5V
4n28 pin 4 --> Teensy Ground


Here are diagrams of the various devices.

Monday, May 06, 2013

SN76489 USB MIDI 100 Firmware

This source code is the software that is used in conjunction with the hardware setup in a previous blog entry in order to create an SN76489 USB MIDI sound module i.e. a SN76489 sound chip controlled via MIDI using a USB device.

The hardware setup can be found here: http://little-scale.blogspot.com.au/2013/02/how-to-build-sn76489-usb-midi-module.html

The source code can be found here: http://milkcrate.com.au/_other/downloads/teensy/SN76489_USB_MIDI_100/SN76489_USB_MIDI_100.ino

Sunday, March 03, 2013

SN76489 USB MIDI Workshop in Chicago!

"The design project and instructions for this were created by little-scale. He gave me permission to put on this workshop.

Participants will create their own SN76489 Synth that may be controlled via USB MIDI. This chip is the sound hardware of the SEGA master system. When sequenced via MIDI the SN76489 can up to three voices.
"


Saturday, April 20, 2013 

Facebook event here: http://www.facebook.com/events/487954271266829/

Sunday, February 17, 2013

SN76489 USB MIDI Workshop Wrap Up

Things worked and the bleepy beeps were made.








Friday, February 15, 2013

How to: Build an SN76489 USB MIDI Module

Overview: 
With a pre-programmed Teensy, it is very easy to make a simple SN76489 USB MIDI module.

The SN76489 USB MIDI maps to the SN76489 in the following way:
MIDI Channel 1 --> SN76489 Square Wave 1
MIDI Channel 2 --> SN76489 Square Wave 2
MIDI Channel 3 --> SN76489 Square Wave 3
MIDI Channel 4 --> SN76489 Noise Channel

Actually, the mapping is pretty much identical to the SMSM mapping for the SN76489 - see this text document for more information. 

The source code for this project can be found here, and should be uploaded to the Teensy using the Teensyduino and Arduino software. 



Pinouts: 





The Quick Version: 

From: To:
Teensy Digital Pin 0 SN76489 Pin 10
Teensy Digital Pin 1 SN76489 Pin 11
Teensy Digital Pin 2 SN76489 Pin 12
Teensy Digital Pin 3 SN76489 Pin 13
Teensy Digital Pin 4 SN76489 Pin 5
Teensy Digital Pin 5 SN76489 Pin 15
Teensy Digital Pin 6 SN76489 Pin 1
Teensy Digital Pin 7 SN76489 Pin 2
Teensy Digital Pin 8 SN76489 Pin 3
Teensy Ground SN76489 Pin 8, Pin 6, Crystal Ground
Teensy 5V SN76489 Pin 16, Crystal 5V
Crystal Clock Signal SN76489 Pin 14
SN76489 Pin 7 Audio Output Signal





The Step By Step Version:

Let's start with an empty breadboard! It has rows separated by a central column, and two pairs of vertical buses (marked + and -). Each row of five points is electrically connected. Each vertical bus is a continuous connection. Easy!


Put the pre-programmed Teensy on the breadboard.


Put the SN76489 on the breadboard, with pin 1 and 16 closest to the Teensy (refer to pinout diagram above). 


Put the crystal on the breadboard, with the 5V pin closest to the SN76489 (refer to pinout diagram above).


Connect the ground of the Teensy to a vertical bus on the breadboard. In this image, I've chosen to do so on the negative (-) blue bus. 


Connect the 5V VCC of the Teensy to a vertical bus on the breadboard. In this image, I've chosen to do so on the positive (+) red bus.  


Connect pin 8 of the SN76489 to the vertical ground bus.


Connect pin 6 of the SN76489 to the vertical ground bus. 


Connect pin 16 of the SN76489 to the vertical 5V bus. 


Connect the ground pin of the crystal to the vertical ground bus.


Connect the 5V pin of the crystal to the vertical 5V bus.


Connect the output pin of the crystal to pin 14 of the SN76489.


Connect digital pin 0 (marked B0) of the Teensy to pin 10 of the SN76489.


Connect digital pin 1 (marked B1) of the Teensy to pin 11 of the SN76489. 


Connect digital pin 2 (marked B2) of the Teensy to pin 12 of the SN76489. 


Connect digital pin 3 (marked B3) of the Teensy to pin 13 of the SN76489. 


 Connect digital pin 5 (marked D0) of the Teensy to pin 15 of the SN76489.

Connect digital pin 6 (marked D1) of the Teensy to pin 1 of the SN76489. 


Connect digital pin 7 (marked D2) of the Teensy to pin 2 of the SN76489.  


Connect digital pin 8 (marked D3) of the Teensy to pin 3 of the SN76489.  


Connect digital pin 4 (marked B7) of the Teensy to pin 5 of the SN76489.  


Take an audio jack. Connect the tip (signal) of the jack to an alligator lead. Connect the ring (ground) of the jack to an alligator lead.


Connect the signal alligator lead to pin 7 of the SN76489, using a small breadboard jumper to connect to the pin. Connect the ground alligator lead to the vertical ground bus.