Package eddiebot_node :: Module songs
[frames] | no frames]

Source Code for Module eddiebot_node.songs

  1  #!/usr/bin/env python 
  2  # Software License Agreement (BSD License) 
  3  # 
  4  # Copyright (c) 2012, Tang Tiong Yew 
  5  # All rights reserved. 
  6  # 
  7  # Redistribution and use in source and binary forms, with or without 
  8  # modification, are permitted provided that the following conditions 
  9  # are met: 
 10  # 
 11  #  * Redistributions of source code must retain the above copyright 
 12  #    notice, this list of conditions and the following disclaimer. 
 13  #  * Redistributions in binary form must reproduce the above 
 14  #    copyright notice, this list of conditions and the following 
 15  #    disclaimer in the documentation and/or other materials provided 
 16  #    with the distribution. 
 17  #  * Neither the name of Willow Garage, Inc. nor the names of its 
 18  #    contributors may be used to endorse or promote products derived 
 19  #    from this software without specific prior written permission. 
 20  # 
 21  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 22  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 23  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 24  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 25  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 26  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 27  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 28  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 29  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 30  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 31  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 32  # POSSIBILITY OF SUCH DAMAGE. 
 33   
34 -def bonus(robot):
35 # a nice bit of goodness from the turtlebot driver by Xuwen Cao and 36 # Morgan Quigley 37 song = ( 38 (76, 16), (76, 16), (72, 8), (76, 16), 39 (79, 32), (67, 32), (72, 24), (67, 24), 40 (64, 24), (69, 16), (71, 16), (70, 8), 41 (69, 16), (79, 16), (76, 16), (72, 8), 42 (74, 16), (71, 24), (60, 16), (79, 8), 43 (78, 8), (77, 8), (74, 8), (75, 8), 44 (76, 16), (67, 8), (69, 8), (72, 16), 45 (69, 8), (72, 8), (74, 8), (60, 16), 46 (79, 8), (78, 8), (77, 8), (74, 8), 47 (75, 8), (76, 16), (76, 4), (78, 4), 48 (84, 16), (84, 8), (84, 16), (84, 16), 49 (60, 16), (79, 8), (78, 8), (77, 8), 50 (74, 8), (75, 8), (76, 16), (67, 8), 51 (69, 8), (72, 16), (69, 8), (72, 8), 52 (74, 16), (70, 4), (72, 4), (75, 16), 53 (69, 4), (71, 4), (74, 16), (67, 4), 54 (69, 4), (72, 16), (67, 8), (67, 16), 55 (60, 24), 56 ) 57 # have to make sure robot is in full mode 58 robot.sci.send([128, 132]) 59 robot.sci.send([140, 1, len(song)]) 60 for note in song: 61 robot.sci.send(note) 62 robot.sci.play_song(1)
63 64 # From: http://www.harmony-central.com/MIDI/Doc/table2.html 65 MIDI_TABLE = {'rest': 0, 'R': 0, 'pause': 0, 66 'G1': 31, 'G#1': 32, 'A1': 33, 67 'A#1': 34, 'B1': 35, 68 69 'C2': 36, 'C#2': 37, 'D2': 38, 70 'D#2': 39, 'E2': 40, 'F2': 41, 71 'F#2': 42, 'G2': 43, 'G#2': 44, 72 'A2': 45, 'A#2': 46, 'B2': 47, 73 74 'C3': 48, 'C#3': 49, 'D3': 50, 75 'D#3': 51, 'E3': 52, 'F3': 53, 76 'F#3': 54, 'G3': 55, 'G#3': 56, 77 'A3': 57, 'A#3': 58, 'B3': 59, 78 79 'C4': 60, 'C#4': 61, 'D4': 62, 80 'D#4': 63, 'E4': 64, 'F4': 65, 81 'F#4': 66, 'G4': 67, 'G#4': 68, 82 'A4': 69, 'A#4': 70, 'B4': 71, 83 84 'C5': 72, 'C#5': 73, 'D5': 74, 85 'D#5': 75, 'E5': 76, 'F5': 77, 86 'F#5': 78, 'G5': 79, 'G#5': 80, 87 'A5': 81, 'A#5': 82, 'B5': 83, 88 89 'C6': 84, 'C#6': 85, 'D6': 86, 90 'D#6': 87, 'E6': 88, 'F6': 89, 91 'F#6': 90, 'G6': 91, 'G#6': 92, 92 'A6': 93, 'A#6': 94, 'B6': 95, 93 94 'C7': 96, 'C#7': 97, 'D7': 98, 95 'D#7': 99, 'E7': 100, 'F7': 101, 96 'F#7': 102, 'G7': 103, 'G#7': 104, 97 'A7': 105, 'A#7': 106, 'B7': 107, 98 99 'C8': 108, 'C#8': 109, 'D8': 110, 100 'D#8': 111, 'E8': 112, 'F8': 113, 101 'F#8': 114, 'G8': 115, 'G#8': 116, 102 'A8': 117, 'A#8': 118, 'B8': 119, 103 104 'C9': 120, 'C#9': 121, 'D9': 122, 105 'D#9': 123, 'E9': 124, 'F9': 125, 106 'F#9': 126, 'G9': 127} 107