Difference between revisions of "Magnetic Resonator Guitar (MR.G)"

From Lofaro Lab Wiki
Jump to: navigation, search
(Touchpad)
(Touchpad)
Line 131: Line 131:
 
The following code sets up the touchpad interface.
 
The following code sets up the touchpad interface.
  
Initialize necessary parameters.
+
;Initialize necessary parameters.
import pygame, sys, os, time
+
  import pygame, sys, os, time
 
   from pygame.locals import *
 
   from pygame.locals import *
 
   from evdev import InputDevice, list_devices
 
   from evdev import InputDevice, list_devices
Line 146: Line 146:
 
   pygame.init()
 
   pygame.init()
  
Define background colors.
+
;Define background colors.
 
   BLACK = (  0,  0,  0)
 
   BLACK = (  0,  0,  0)
 
   WHITE = (255, 255, 255)
 
   WHITE = (255, 255, 255)
Line 156: Line 156:
 
   YELLOW =(255, 255,  0)
 
   YELLOW =(255, 255,  0)
  
Enable display.
+
;Enable display.
 
   allSprites = pygame.sprite.Group(circle)
 
   allSprites = pygame.sprite.Group(circle)
 
   pygame.mouse.set_visible(False)
 
   pygame.mouse.set_visible(False)
Line 162: Line 162:
 
   pygame.display.set_caption('Drawing')
 
   pygame.display.set_caption('Drawing')
  
Define custom cursor.
+
;Define custom cursor.
 
   class Circle(pygame.sprite.Sprite):
 
   class Circle(pygame.sprite.Sprite):
 
     def __init__(self):
 
     def __init__(self):
Line 172: Line 172:
 
         self.rect.center = pygame.mouse.get_pos()
 
         self.rect.center = pygame.mouse.get_pos()
  
Set logo as background.
+
;Set logo as background.
 
   logo = pygame.image.load(os.path.join('MRG Logo.png'))
 
   logo = pygame.image.load(os.path.join('MRG Logo.png'))
 
   logo = pygame.transform.scale(logo,(480,320))
 
   logo = pygame.transform.scale(logo,(480,320))
Line 178: Line 178:
 
   screen.blit(logo, (0, 0))
 
   screen.blit(logo, (0, 0))
  
Enable custom cursor.
+
;Enable custom cursor.
 
   allSprites = pygame.sprite.Group(circle)
 
   allSprites = pygame.sprite.Group(circle)
 
   pygame.mouse.set_visible(False)
 
   pygame.mouse.set_visible(False)
  
Determine and update location of cursor.
+
;Determine and update location of cursor.
 
   running = True
 
   running = True
 
   while running: # run the game loop
 
   while running: # run the game loop

Revision as of 01:38, 3 December 2014

Logo.jpg

Overview

The Magnetic Resonator Guitar (MR.G) was inspired by Drexel's Magnetic Resonator Piano. Much like the Magnetic Resonator Piano, MR.G is a hybrid acoustic-electric instrument. While the sound is processed electronically, the music the guitar produces is entirely acoustic. There are no speakers, with the only amplification being in connection to the electromagnetic actuation.

The aim of this project is to expand the musical capacity of the guitar. Over the past few decades, artists have been employing digital techniques to create new forms of music. Some instruments have been modified precisely for this purpose. For example, the keyboard introduced techno to the piano. Our goal is to provide a similar alteration to the guitar, as it is one of the most popular instruments. The difference here is that we seek to preserve the traditional acoustic sound alongside the new techno version. The following is a step by step guide to creating a device that can be attached to an acoustic guitar. It will allow users to add digital sound effects, play songs through resonation, or simply play the guitar as originally intended. We hope this expansion will give musicians more creative freedom. It is provided in an open source format to encourage both professionals and hobbyists to enjoy MR. G.

Background

The basic idea of MR.G is the use of resonant frequencies to excite guitar strings. All objects have a frequency at which they vibrate, known as the resonant frequency. If a wave form (it may be sound, electromagnetic, etc.) of that frequency hits an object, it will begin to resonate. In this case, that frequency is the note at which each string is tuned.

The chosen signal for for this project is electromagnetic. The initial sound wave enters through either a microphone or from the Raspberry Pi. It is then amplified and sent out to the strings, which result in the vibration. The sound produced is similar to that of a violin as opposed to the traditional plucking.

Schematic

Schematic.jpg

PCB Design

If you wish to use the PCB developed for this project, the necessary Gerber files can be found at the end of this report.

If you wish to create your own version of the board, we recommend either Fritzing or KiCAD software.

Parts list

to populate PCB
Resistors
1K = R1,R6,R14
2.2K = R2
10K = R4,R5,R13
22K = R9,R10,R11
100K = R3,R7
220K = R12
1M = R8
Capacitors
0.1uF (Tantalum) = C2,C4
0.1uF (Mylar) = C5,C6,C10,C12
0.33uF (Tantalum) = C1,C3
1.0uF (Tantalum) = C7
10uF (Electrolytic) = C8
100uF (Electrolytic) = C9
1000uF (Electrolytic) = C11
ICs
Voltage Regulators
78M16 or 78M15 = VR1
78M12A = VR2
Amplifiers
TLC37M4CN = U1
LM1875T = U2
Microphone

Raspberry Pi Setup

Code

For Audio processing on the Raspberry Pi please see AudioStatic's Low-Latency Audio on RasPi tutorial

For handling the guitar's signal we used a Python library called PYO. Shown below we have all the code we have used on for producing various effects.

All coding files can be found at https://github.com/kherring/MRG.

Simple PYO Server

The following code will instantiate a pyo server on the Raspberry Pi and output a Sine wave. Please note that you must be using X11forwarding in order for this to function. Also, if you're running this in IDLE, you do not need to include s.gui(). However, if you're running this code from terminal you will need to append s.gui() to all of your PYO code. If s.gui() is not at the end of the code, when it is being run in terminal, the code will finish being executed before it has actually had time to send any information to your computer for processing.

 from pyo import *
 s = Server().boot()
 s.start()
 a = Sine(freq=440,phase=0,mul=0.1,add=0).out()
 s.gui()

Frequency Tracker

The following code will sample the audio input of your computer and output the corresponding frequency of the input signal, by using the Yin Algorithm [1].

 from pyo import *
 s = Server(duplex=1).boot()
 s.start()
 a = Input(0,1,0)
 fq = Yin(a,tolerance=0.2,winsize=1024,mul=1,add=0)
 wave = Sine(freq=fq,phase=0,mul=1,add=0).out()
 s.gui()

Phaser

The following code incorporates several synthesis operations and techniques. This code uses LFOs, which stand for low frequency oscillator. Basically, they are used for creating rhythm and they typically oscillate below 30Hz (more information may be found in this wiki article: [2]).

This first example uses the PYO function Noise as an input, just so you may test this out on your computer and hear how the effect sounds.

 from pyo import *
 s = Server().boot()
 s.start()
 fade = Fader(fadein=.1,mul=0.7).play()
 a = Noise(mul=.25,add=0)
 lf1 = Sine(freq=[.1,.15],mul=100,add=250)
 lf2 = Sine(freq=[.18,.15],mul=.4,add=1.5)
 b = Phaser(a,freq=lf1,spread=lf2,q=1,num=20,mul=.5).out(0)
 s.gui()

Now, to make the previous code accept the guitar input. All you have to do is change out the following line:

 a = Noise(mul=.25,add=0)

to

 a = Input(chnl=0,mul=1,add=0)

Now your code should look like this:

 from pyo import *
 s = Server().boot()
 s.start()
 fade = Fader(fadein=.1,mul=0.7).play()
 a = Input(chnl=0,mul=1,add=0)
 lf1 = Sine(freq=[.1,.15],mul=100,add=250)
 lf2 = Sine(freq=[.18,.15],mul=.4,add=1.5)
 b = Phaser(a,freq=lf1,spread=lf2,q=1,num=20,mul=.5).out(0)
 s.gui()

Sawtooth

The following code samples the input audio using the Yin algorithm and outputs to a sawtooth waveform.

 from pyo import *
 s = Server().boot()
 s.start()
 a = Input(0,1,0)
 yin = Yin(a,tolerance=0.2,minfreq=60,maxfreq=1500,cutoff=1500,winsize=1024,mul=1,add=0)
 wave = SuperSaw(freq=yin,detune=0.5,bal=0.7,mul=1,add=0).out()
 s.gui() 

Touchpad

The following code sets up the touchpad interface.

Initialize necessary parameters.
 import pygame, sys, os, time
 from pygame.locals import *
 from evdev import InputDevice, list_devices
 devices = map(InputDevice, list_devices())
 eventX=""
 for dev in devices:
   if dev.name == "ADS7843 Touchscreen":
      eventX = dev.fn
 print eventX
 os.environ["SDL_FBDEV"] = "/dev/fb1"
 os.environ["SDL_MOUSEDRV"] = "TSLIB"
 os.environ["SDL_MOUSEDEV"] = eventX
 pygame.init()
Define background colors.
 BLACK = (  0,   0,   0)
 WHITE = (255, 255, 255)
 RED   = (255,   0,   0)
 GREEN = (  0, 255,   0)
 BLUE  = (  0,   0, 255)
 CYAN  = (  0, 255, 255)
 MAGENTA=(255,   0, 255)
 YELLOW =(255, 255,   0)
Enable display.
 allSprites = pygame.sprite.Group(circle)
 pygame.mouse.set_visible(False)
 screen = pygame.display.set_mode((480,320), 0, 32)
 pygame.display.set_caption('Drawing')
Define custom cursor.
 class Circle(pygame.sprite.Sprite):
   def __init__(self):
       pygame.sprite.Sprite.__init__(self)
       self.image = pygame.Surface((20,20))
       self.image.fill(BLUE)
       self.rect = self.image.get_rect()
   def update(self):
       self.rect.center = pygame.mouse.get_pos()
Set logo as background.
 logo = pygame.image.load(os.path.join('MRG Logo.png'))
 logo = pygame.transform.scale(logo,(480,320))
 logo = logo.convert()   
 screen.blit(logo, (0, 0))
Enable custom cursor.
 allSprites = pygame.sprite.Group(circle)
 pygame.mouse.set_visible(False)
Determine and update location of cursor.
 running = True
 while running: # run the game loop
   for event in pygame.event.get():
       if event.type == QUIT:
           pygame.quit()
           sys.exit()
           running = False
   allSprites.clear(screen,logo)
   allSprites.update()
   allSprites.draw(screen)
       if event.type == KEYDOWN and event.key == K_ESCAPE:
           running = False
       pygame.display.update()</span>

Prototype

Insert Jpeg

Files

https://drive.google.com/file/d/0Bxk2aCp7AwzON19ZOGhzZlJISjQ/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOc1lUR2ZKcE5udGM/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzObTN5VVd5NVNXTk0/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOZVlHS3BDQmE0bjA/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOVWNuTDZ0SzJwQzg/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOSngyZHRBTGcyWGM/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOLUNJYVNfWVlxdVE/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOQi0xOWVzNmF5RjQ/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOa3FkbHRtbGdWZWc/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzOTEtzd3FrUy12WlE/view?usp=sharing
https://drive.google.com/file/d/0Bxk2aCp7AwzORkVfeEN4ZS1BQUE/view?usp=sharing