Go Down

Topic: Planet Funk, Chase the Sun??? (Read 458 times) previous topic - next topic

dizzwold

Hi all,

 This is a very silly question, but;

 Has anyone ever programmed an Arduino to play the tune, Chase the Sun by Planet Funk?

 You know the the tune everyone shout's at the UK Darts World Masters.

 Looking to try and play this through a piezo, just can't find the notes needed etc.

 Like i said, a very silly 'Q'.

 Any thoughts?

 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

Peter_n


el_supremo

The code at https://code.google.com/p/miditones/ worked for me.

This works on a Nano when you have the Playtune library installed.
Code: [Select]
// https://code.google.com/p/arduino-playtune/

//**************************************************
//
// Test of playtune library for Arduino NANO
//
// L. Shustek, 31 Jan 2011, initial release.
// L. Shustek, 27 Feb 2011, new score data
//
//**************************************************


#include <Playtune.h>

//------------------------------------------------
//   scores are put in program space memory
//------------------------------------------------


// Playtune bytestream for file "Planet Funk - Chase The sun.mid" created by MIDITONES V1.6 on Sun Mar 15 09:28:27 2015
// command line: miditones Planet Funk - Chase The sun
byte PROGMEM score [] = {
0x90,77, 0,200, 0x80, 0,227, 0x90,77, 0,200, 0x80, 0,13, 0x90,75, 0,200, 0x80, 0,13,
0x90,73, 0,200, 0x80, 0,13, 0x90,72, 1,159, 0x80, 0,227, 0x90,72, 0,200, 0x80, 0,13,
0x90,73, 0,200, 0x80, 0,13, 0x90,72, 0,200, 0x80, 0,13, 0x90,70, 0,200, 0x80, 0,227,
0x90,68, 1,159, 0x80, 0,227, 0x90,65, 0,200, 0x80, 0,13, 0x90,68, 0,200, 0x80, 0,13,
0x90,70, 0,200, 0x80, 0,13, 0x90,72, 0,200, 0x80, 0,227, 0x90,70, 6,164, 0x80, 0xf0};
// This score contains 103 bytes, and 1 tone generator is used.


Playtune pt;

void setup() {

  // Enable all 3 NANO timers for notes that are output on digital pins 10, 11, and 12.
  // Those pins should be wired to 500-ohm resistors, the other ends of which should be connected together
  // to one terminal of an 8-ohm speaker.  The other terminal of the speaker should be connected to ground. 
  // No other hardware is needed!

  pt.tune_initchan (10);
//  pt.tune_initchan (11);
//  pt.tune_initchan (12);
}

void loop () {
  pt.tune_playscore (score);  /* start playing */
  while (pt.tune_playing) ;   /* wait here until playing stops */
  // Play it once. It is irritating
  while(1);
}





Pete
Don't send me technical questions via Private Message.

Peter_n

Cool  8)
I didn't test it. I have only an Uno with speaker here, and it needs three resistors from three outputs.

el_supremo

I think the code I posted should work on an UNO. The code only uses pin 10. The comments about three pins were from the original version of the code which had a much longer piece of music with three separate tone outputs.
BTW I used a 150 ohm resistor to an 8ohm speaker and it worked fine.

Pete
Don't send me technical questions via Private Message.

Peter_n

It is working on a Uno  ;D
I had to make a few changes to Playtune to make it work with Arduino IDE 1.6.0
Only 9% code and 2% ram is used, so it can be a lot longer.

It is hard to get the same feeling of the catchy tune from an Arduino speaker.
The Arduino can also play samples from SD card : https://github.com/TMRh20/TMRpcm/wiki

Go Up