Skip to contentSkip to conversation

Tune generation tool

FILE Vincent Pelletier 3 participants 9 messages Jul 12, 2005 – Jul 14, 2005

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here is the source of a little tool to generate tunes for Grub 2 play command.
Quick coded, could be more powerful but I'm not sure it's worth the work.

I'm not sure if it should enter the cvs, too. And if it does, where ?

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1BwTFEQoKRQyjtURAtk4AJ4hZTZmskufX/alWLRqZUiNoZ12nwCeMCC1 XDZsg5lKFEmX2s13/bjKt78=
=0X7Z
-----END PGP SIGNATURE-----

/* The 12th root of 2. Sort of. */
#define T_TEMP_SCALE 1.0594630943592952645
#define T_DOWN_ONE_HALF(x) ((short) (x / T_TEMP_SCALE))
#define T_UP_ONE_HALF(x) ((short) (x * T_TEMP_SCALE))
#define T_DOWN_ONE_OCTAVE(x) ((short) (x / 2))
#define T_UP_ONE_OCTAVE(x) ((short) (x * 2))
#define T_REST ((short) 0)
#define T_FINE ((short) (-1))

#define T_b_3 T_UP_ONE_OCTAVE (T_b_2)
#define T_b_F_3 T_UP_ONE_OCTAVE (T_b_F_2)
#define T_a_S_3 T_b_F_3
#define T_a_3 T_UP_ONE_OCTAVE (T_a_2)
#define T_a_F_3 T_UP_ONE_OCTAVE (T_a_F_2)
#define T_g_S_3 T_a_F_3
#define T_g_3 T_UP_ONE_OCTAVE (T_g_2)
#define T_g_F_3 T_f_S_3
#define T_f_S_3 T_UP_ONE_OCTAVE (T_f_S_2)
#define T_f_3 T_UP_ONE_OCTAVE (T_f_2)
#define T_e_3 T_UP_ONE_OCTAVE (T_e_2)
#define T_e_F_3 T_UP_ONE_OCTAVE (T_e_F_2)
#define T_d_S_3 T_e_F_3
#define T_d_3 T_UP_ONE_OCTAVE (T_d_2)
#define T_d_F_3 T_c_S_3
#define T_c_S_3 T_UP_ONE_OCTAVE (T_c_S_2)
#define T_c_3 T_UP_ONE_OCTAVE (T_c_2)

#define B6      T_b_3
#define BF6     T_b_F_3
#define AS6     T_a_S_3
#define A6      T_a_3
#define AF6     T_a_F_3
#define GS6     T_g_S_3
#define G6      T_g_3
#define GF6     T_g_F_3
#define FS6     T_f_S_3
#define F6      T_f_3
#define E6      T_e_3
#define EF6     T_e_F_3
#define DS6     T_d_S_3
#define D6      T_d_3
#define DF6     T_d_F_3
#define CS6     T_c_S_3
#define C6      T_c_3

#define T_b_2 T_UP_ONE_OCTAVE (T_b_1)
#define T_b_F_2 T_UP_ONE_OCTAVE (T_b_F_1)
#define T_a_S_2 T_b_F_2
#define T_a_2 T_UP_ONE_OCTAVE (T_a_1)
#define T_a_F_2 T_UP_ONE_OCTAVE (T_a_F_1)
#define T_g_S_2 T_a_F_2
#define T_g_2 T_UP_ONE_OCTAVE (T_g_1)
#define T_g_F_2 T_f_S_2
#define T_f_S_2 T_UP_ONE_OCTAVE (T_f_S_1)
#define T_f_2 T_UP_ONE_OCTAVE (T_f_1)
#define T_e_2 T_UP_ONE_OCTAVE (T_e_1)
#define T_e_F_2 T_UP_ONE_OCTAVE (T_e_F_1)
#define T_d_S_2 T_e_F_2
#define T_d_2 T_UP_ONE_OCTAVE (T_d_1)
#define T_d_F_2 T_c_S_2
#define T_c_S_2 T_UP_ONE_OCTAVE (T_c_S_1)
#define T_c_2 T_UP_ONE_OCTAVE (T_c_1)

#define B5      T_b_2
#define BF5     T_b_F_2
#define AS5     T_a_S_2
#define A5      T_a_2
#define AF5     T_a_F_2
#define GS5     T_g_S_2
#define G5      T_g_2
#define GF5     T_g_F_2
#define FS5     T_f_S_2
#define F5      T_f_2
#define E5      T_e_2
#define EF5     T_e_F_2
#define DS5     T_d_S_2
#define D5      T_d_2
#define DF5     T_d_F_2
#define CS5     T_c_S_2
#define C5      T_c_2

#define T_b_1 T_UP_ONE_HALF (T_b_F_1)
#define T_b_F_1 T_UP_ONE_HALF (T_a_1)
#define T_a_S_1 T_b_F_1
#define T_a_1 ((short) (440))
#define T_a_F_1 T_DOWN_ONE_HALF (T_a_1)
#define T_g_S_1 T_a_F_1
#define T_g_1 T_DOWN_ONE_HALF (T_a_F_1)
#define T_g_F_1 T_f_S_1
#define T_f_S_1 T_DOWN_ONE_HALF (T_g_1)
#define T_f_1 T_DOWN_ONE_HALF (T_f_S_1)
#define T_e_1 T_DOWN_ONE_HALF (T_f_1)
#define T_e_F_1 T_DOWN_ONE_HALF (T_e_1)
#define T_d_S_1 T_e_F_1
#define T_d_1 T_DOWN_ONE_HALF (T_e_F_1)
#define T_d_F_1 T_c_S_1
#define T_c_S_1 T_DOWN_ONE_HALF (T_d_1)
#define T_c_1 T_DOWN_ONE_HALF (T_c_S_1)

#define B4      T_b_1
#define BF4     T_b_F_1
#define AS4     T_a_S_1
#define A4      T_a_1
#define AF4     T_a_F_1
#define GS4     T_g_S_1
#define G4      T_g_1
#define GF4     T_g_F_1
#define FS4     T_f_S_1
#define F4      T_f_1
#define E4      T_e_1
#define EF4     T_e_F_1
#define DS4     T_d_S_1
#define D4      T_d_1
#define DF4     T_d_F_1
#define CS4     T_c_S_1
#define C4      T_c_1

#define T_b T_DOWN_ONE_OCTAVE (T_b_1)
#define T_b_F T_DOWN_ONE_OCTAVE (T_b_F_1)
#define T_a_S T_b_F
#define T_a T_DOWN_ONE_OCTAVE (T_a_1)
#define T_a_F T_DOWN_ONE_OCTAVE (T_a_F_1)
#define T_g_S T_a_F
#define T_g T_DOWN_ONE_OCTAVE (T_g_1)
#define T_g_F T_f_S
#define T_f_S T_DOWN_ONE_OCTAVE (T_f_S_1)
#define T_f T_DOWN_ONE_OCTAVE (T_f_1)
#define T_e T_DOWN_ONE_OCTAVE (T_e_1)
#define T_e_F T_DOWN_ONE_OCTAVE (T_e_F_1)
#define T_d_S T_e_F
#define T_d T_DOWN_ONE_OCTAVE (T_d_1)
#define T_d_F T_c_S
#define T_c_S T_DOWN_ONE_OCTAVE (T_c_S_1)
#define T_c T_DOWN_ONE_OCTAVE (T_c_1)

#define B3      T_b
#define BF3     T_b_F
#define AS3     T_a_S
#define A3      T_a
#define AF3     T_a_F
#define GS3     T_g_S
#define G3      T_g
#define GF3     T_g_F
#define FS3     T_f_S
#define F3      T_f
#define E3      T_e
#define EF3     T_e_F
#define DS3     T_d_S
#define D3      T_d
#define DF3     T_d_F
#define CS3     T_c_S
#define C3      T_c

#define T_b_0 T_DOWN_ONE_OCTAVE (T_b)
#define T_b_F_0 T_DOWN_ONE_OCTAVE (T_b_F)
#define T_a_S_0 T_b_F_0
#define T_a_0 T_DOWN_ONE_OCTAVE (T_a)
#define T_a_F_0 T_DOWN_ONE_OCTAVE (T_a_F)
#define T_g_S_0 T_a_F_0
#define T_g_0 T_DOWN_ONE_OCTAVE (T_g)
#define T_g_F_0 T_f_S_0
#define T_f_S_0 T_DOWN_ONE_OCTAVE (T_f_S)
#define T_f_0 T_DOWN_ONE_OCTAVE (T_f)
#define T_e_0 T_DOWN_ONE_OCTAVE (T_e)
#define T_e_F_0 T_DOWN_ONE_OCTAVE (T_e_F)
#define T_d_S_0 T_e_F_0
#define T_d_0 T_DOWN_ONE_OCTAVE (T_d)
#define T_d_F_0 T_c_S_0
#define T_c_S_0 T_DOWN_ONE_OCTAVE (T_c_S)
#define T_c_0 T_DOWN_ONE_OCTAVE (T_c)

#define B2      T_b_0
#define BF2     T_b_F_0
#define AS2     T_a_S_0
#define A2      T_a_0
#define AF2     T_a_F_0
#define GS2     T_g_S_0
#define G2      T_g_0
#define GF2     T_g_F_0
#define FS2     T_f_S_0
#define F2      T_f_0
#define E2      T_e_0
#define EF2     T_e_F_0
#define DS2     T_d_S_0
#define D2      T_d_0
#define DF2     T_d_F_0
#define CS2     T_c_S_0
#define C2      T_c_0

struct note
{
short pitch;
short duration;
};

struct melody
{
char *name;
int measure;
struct note *next;
struct note note[];
};

#include <stdio.h>
#include "common.h"

struct melody tune1 =

  { "FSF_Song", 160, NULL, {
    /* The Free Software Song.  Measure: 7/4.  */
    { T_d_2, 16 }, { T_c_2,  8 }, { T_b_1, 16 }, { T_a_1, 16 },
    { T_b_1, 16 }, { T_c_2,  8 }, { T_b_1,  8 }, { T_a_1,  8 }, { T_g_1, 16 },
    { T_g_1, 24 }, { T_a_1, 24 }, { T_b_1,  8 },
    { T_c_2, 24 }, { T_b_1, 14 }, { T_REST, 2 }, { T_b_1,  8 }, { T_d_2, 8 },
    { T_a_1, 22 }, { T_REST, 2 }, { T_a_1, 32 },
    { T_c_2, 16 }, { T_d_2,  8 }, { T_c_2, 16 }, { T_b_1, 24 },
    { T_d_2, 16 }, { T_c_2,  8 }, { T_b_1, 16 }, { T_a_1, 16 },
    { T_b_1, 16 }, { T_c_2,  8 }, { T_b_1,  8 }, { T_a_1,  8 }, { T_g_1, 16 },
    { T_g_1, 24 }, { T_a_1, 24 }, { T_b_1,  8 },
    { T_c_2, 24 }, { T_b_1, 14 }, { T_REST, 2 }, { T_b_1,  8 }, { T_d_2, 8 },
    { T_a_1, 22 }, { T_REST, 2 }, { T_a_1, 30 }, { T_REST, 2 },
    { T_a_1, 56 }, { T_FINE, 0 }

} };

struct melody tune2 =

  { "I_Feel_Pretty", 160, NULL, {
    /* I feel pretty.  Measure: 3/4.  By Leonard Bernstein.  */
    { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 20 },
    { T_REST, 8 }, { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 20 },
    { T_REST, 8 }, { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 12 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 12 }, { T_f_1,  8 },
    { T_c_2, 32 },
    { T_b_F_1,8 }, { T_a_1,  8 },
    { T_g_1,  4 }, { T_f_1, 20 },
    { T_REST, 8 }, { T_g_1,  8 }, { T_a_1,  8 },
    { T_b_F_1,12}, { T_a_1,  4 }, { T_g_1,  4 }, { T_f_1, 4 },
    { T_e_1, 16 }, { T_d_1,  3 }, { T_e_1,  2 }, { T_d_1, 3 },
    { T_c_1, 56 }, { T_FINE, 0 }

} };

struct melody tune3 =

  { "Summertime", 120, NULL, {
    /* Summertime.  Measure: 4/4.  By George & Ira Gershwin.  */
    { T_b_1,  8 }, { T_g_1,  8 },
    { T_b_1, 36 }, { T_REST, 4 }, { T_a_1,  6 }, { T_g_1,  2 },
    { T_a_1,  6 }, { T_b_1,  2 }, { T_g_1,  8 },
    { T_e_1, 16 }, { T_b,   24 }, { T_REST, 8 },
    { T_b_1,  8 }, { T_g_1,  8 },
    { T_a_1,  3 }, { T_REST, 1 }, { T_a_1, 28 },
    { T_REST, 8 }, { T_g_1,  6 }, { T_e_1,  2 },
    { T_g_1,  6 }, { T_e_1,  2 }, { T_g_1,  8 },
    { T_f_S_1,48}, { T_REST, 4 }, { T_b_1,  8 }, { T_g_1,  4 },
    { T_b_1,  3 }, { T_REST, 1 }, { T_b_1,  7 }, { T_REST, 1 }, { T_b_1, 20 },
    { T_REST, 8 }, { T_a_1,  6 }, { T_g_1,  2 },
    { T_a_1,  6 }, { T_b_1,  2 }, { T_g_1,  8 },
    { T_e_1, 16 }, { T_b,   32 }, { T_REST, 8 },
    { T_b,    8 }, { T_d_1,  8 }, { T_b,    4 },
    { T_d_1,  4 }, { T_e_1,  8 }, { T_g_1,  8 },
    /* Keen attempt at a glissando.  */
    { T_b_1,  2 }, { T_b_1 + (T_b_1 - T_a_1) / 3, 1 },
    { T_b_1 + 2 * (T_b_1 - T_a_1) / 3, 1 },
    { T_a_1, 12 }, { T_g_1, 15 }, { T_REST,  1 },
    { T_g_1,  4 }, { T_e_1, 68 },
    { T_FINE, 0 }

} };

struct melody tune4 =

  { "Indiana_Jones_Theme", 250, NULL, {
    /* Indiana Jones Theme.  Measure: 4/4.  By John Williams.  */
    { T_e_1, 4 }, { T_REST, 8 }, { T_f_1, 4 },
    { T_g_1, 4 }, { T_REST, 4 }, { T_c_2, 24 },
    { T_REST, 16 }, { T_d_1, 4 }, { T_REST, 8 }, { T_e_1, 4 },
    { T_f_1, 32 },
    { T_REST, 16 }, { T_g_1, 4 }, { T_REST, 8 }, { T_a_1, 4 },
    { T_b_1, 4 }, { T_REST, 4 }, { T_f_2, 24 },
    { T_REST, 16 }, { T_a_1, 4 }, { T_REST, 8 }, { T_b_1, 4 },
    { T_c_2, 8 }, { T_REST, 8 }, { T_d_2, 12 }, { T_REST, 4 },
    { T_e_2, 8 }, { T_REST, 8 },
    { T_e_1, 4 }, { T_REST, 8 }, { T_f_1, 4 },
    { T_g_1, 4 }, { T_REST, 4 }, { T_c_2, 24 },
    { T_REST, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_e_2, 4 },
    { T_f_2, 32 },
    { T_REST, 16 }, { T_g_1, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_e_2, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_e_2, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_f_2, 16 }, { T_e_2, 4 }, { T_REST, 8 }, { T_d_2, 4 },
    { T_c_2, 32 }, { T_FINE, 0 }

} };

struct melody tune5 =

  { "Beverly Hills Cop.", 600, NULL, {
    /* Axel F, soundtrack of Beverly Hills Cop.  By Harold
       Faltermeyer, composed by Frank Jr.  ([email protected]).  */
    {  T_e_1,  8 }, { T_REST, 16 }, {  T_g_1,  6 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_e_1,  4 }, { T_REST,  8 }, {  T_e_1,  5 },
    { T_REST,  2 }, {  T_a_1,  5 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  8 }, {  T_d_1,  5 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  8 }, { T_REST, 16 }, {  T_b_1,  6 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_e_1,  6 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  2 }, {  T_c_2,  4 }, { T_REST,  8 }, {  T_b_1,  5 },
    { T_REST,  8 }, {  T_g_1,  3 }, { T_REST,  4 }, { T_REST,  8 },
    {  T_e_1,  3 }, { T_REST,  4 }, { T_REST,  8 }, {  T_b_1,  3 },
    { T_REST,  4 }, { T_REST,  8 }, {  T_e_2,  4 }, { T_REST,  8 },
    {  T_e_1,  3 }, { T_REST,  4 }, {  T_d_1,  5 }, { T_REST,  8 },
    {  T_d_1,  5 }, {    T_a,  4 }, { T_REST,  4 }, { T_REST,  8 },
    {  T_f_1, 12 }, { T_REST,  4 }, {  T_e_1, 92 }, { T_REST, 16 },
    { T_REST, 32 }, { T_FINE,  0 }

} };

struct melody tune6 =
{ "Star Trek: The Next Generation", 600, NULL, {

    /* Music from the `Star Trek: The Next Generation' episode `Inner
       Light'.  Composed by Jay Chattaway.  */
    {  T_f_1, 64 }, { T_REST, 16 }, {  T_g_1, 32 }, { T_REST,  8 },
    {  T_f_1, 42 }, { T_REST,  8 }, { T_REST,  8 }, {  T_b_1, 64 },
    { T_REST,  8 }, { T_REST, 16 }, { T_REST,  8 }, {  T_b_1, 42 },
    { T_REST,  8 }, { T_REST,  8 }, {  T_c_2, 64 }, { T_REST,  8 },
    { T_REST, 16 }, {  T_f_2, 42 }, { T_REST,  8 }, {  T_e_2, 85 },
    { T_REST,  8 }, { T_REST, 16 }, {  T_c_2, 64 }, { T_REST, 16 },
    {  T_g_2, 42 }, { T_REST,  8 }, {  T_f_2, 64 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_f_1, 42 }, { T_REST,  8 }, {  T_e_2, 64 },
    {  T_c_2, 21 }, { T_REST,  8 }, {  T_b_1, 42 }, { T_REST,  8 },
    {  T_g_1, 85 }, { T_FINE,  0 }

} };

struct melody tune99 =

  { "Tetris_Theme", 300, NULL, {
    /*  */
    /* si  B
     * la  A
     * sol G
     * fa  F
     * mi  E
     * re  D
     * do  C
     * black = 16 */
    { E5 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 8 }, { E5 , 4 }, { D5 , 4 }, { C5 , 8 }, { B4 , 8 },
    { A4 , 16 }, { A4 , 8 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 24 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 32 },
    { T_REST , 8 }, { D5 , 16 }, { F5 , 8 }, { A6 , 16 }, { G5 , 8 }, { F5 , 8 },
    { E5 , 24 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 16 }, { T_REST , 16 },
    { E5 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 8 }, { E5 , 4 }, { D5 , 4 }, { C5 , 8 }, { B4 , 8 },
    { A4 , 16 }, { A4 , 8 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 24 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 32 },
    { T_REST , 8 }, { D5 , 16 }, { F5 , 8 }, { A6 , 16 }, { G5 , 8 }, { F5 , 8 },
    { E5 , 24 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 16 }, { T_REST , 16 },
    { E4 , 32 }, { C4 , 32 },
    { D4 , 32 }, { B3 , 32 },
    { C4 , 32 }, { A3 , 32 },
    { GF2 , 32 }, { B3 , 16 }, { T_REST , 16 },
    { E4 , 32 }, { C4 , 32 },
    { D4 , 32 }, { B3 , 32 },
    { C4 , 16 }, { E4 , 16 }, { A4 , 32 },
    { GS4 , 32 }, { T_REST , 16 }, { T_REST , 16 },
    { E5 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 8 }, { E5 , 4 }, { D5 , 4 }, { C5 , 8 }, { B4 , 8 },
    { A4 , 16 }, { A4 , 8 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 24 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 32 },
    { T_REST , 8 }, { D5 , 16 }, { F5 , 8 }, { A6 , 16 }, { G5 , 8 }, { F5 , 8 },
    { E5 , 24 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 16 }, { T_REST , 16 },
    { E5 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 8 }, { E5 , 4 }, { D5 , 4 }, { C5 , 8 }, { B4 , 8 },
    { A4 , 16 }, { A4 , 8 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 24 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 32 },
    { T_REST , 8 }, { D5 , 16 }, { F5 , 8 }, { A6 , 16 }, { G5 , 8 }, { F5 , 8 },
    { E5 , 24 }, { C5 , 8 }, { E5 , 16 }, { D5 , 8 }, { C5 , 8 },
    { B4 , 16 }, { B4 , 8 }, { C5 , 8 }, { D5 , 16 }, { E5 , 16 },
    { C5 , 16 }, { A4 , 16 }, { A4 , 16 }, { T_REST , 16 },
    { T_FINE, 0 }

} };

struct melody *tune[] = { &tune1, &tune2, &tune3, &tune4, &tune5, &tune6, &tune99 };

int main(void)
{
int a,b;
FILE *f;
for(a=0;a<sizeof(tune)/sizeof(tune[0]);a++)

  {
    b=0;
    printf("Number : %i\n",a);
    f=fopen(tune[a]->name,"w");
    fprintf(f,"%c%c%c%c",tune[a]->measure&0xFF,tune[a]->measure>>8&0xFF,
        tune[a]->measure>>16&0xFF,tune[a]->measure>>24&0xFF);
    while(tune[a]->note[b].pitch!=T_FINE)
    {
      fprintf(f,"%c%c%c%c",
          tune[a]->note[b].pitch&0xFF,tune[a]->note[b].pitch>>8&0xFF,
          tune[a]->note[b].duration&0xFF,tune[a]->note[b].duration>>8&0xFF);
      b++;
    }
    fclose(f);

}
}

#1 lore raw

Vincent Pelletier <[email protected]> writes:

Hi Vincent,

Quoted 5 lines

Here is the source of a little tool to generate tunes for Grub 2 play command.
Quick coded, could be more powerful but I'm not sure it's worth the work.

I'm not sure if it should enter the cvs, too. And if it does, where ?

Perhaps `contrib/util/i386/' or so?

I am not sure if it has to enter CVS, but I have no objections against it. Can you add the copyright header and copyright years before it is committed?

Thanks,
Marco

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 1 line · Marco Gerards

Perhaps `contrib/util/i386/' or so?

Good idea.

Quoted 3 lines

I am not sure if it has to enter CVS, but I have no objections against it. Can you add the copyright header and copyright years before it is committed?

Sure. Do I send a patch or the bare files ?
I'll also check the formatting guidelines are followed in my code ;) .

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1YMpFEQoKRQyjtURAk52AJ9lju/FXYU3J0SCnBVvgyJ8SwiiowCeOtcw XYTZYl0cEEmItC2DDvs2oek=
=64vf
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

#3 lore raw
Quoted 6 lines · Vincent Pelletier
Quoted 3 lines

I am not sure if it has to enter CVS, but I have no objections against it. Can you add the copyright header and copyright years before it is committed?

Sure. Do I send a patch or the bare files ?
I'll also check the formatting guidelines are followed in my code ;) .

Both are fine for me.

--
Marco

#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 1 line · Marco Gerards

Both are fine for me.

Here it is. Merged everything in the c file to be cleaner.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1Zo2FEQoKRQyjtURAiZ1AJwKWv+yVysANtUG3+Z1cBwnzYCWUwCgsDHa 3m8e/Vi+mvD34UtTcKCukPo=
=s0Qh
-----END PGP SIGNATURE-----

/* gentunes.c -- Generates tune files for Grub 2 "play" command. */ /*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005 Free Software Foundation, Inc.
*

 *  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
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include <stdio.h>

/* The 12th root of 2. Sort of. */
#define T_TEMP_SCALE 1.0594630943592952645
#define T_DOWN_ONE_HALF(x) ((short) (x / T_TEMP_SCALE))
#define T_UP_ONE_HALF(x) ((short) (x * T_TEMP_SCALE))
#define T_DOWN_ONE_OCTAVE(x) ((short) (x / 2))
#define T_UP_ONE_OCTAVE(x) ((short) (x * 2))
#define T_REST ((short) 0)
#define T_FINE ((short) (-1))

/* Notes ranging from C to B in octaves 2 to 6.
German (?) notation and GNU/Hurd notation supported. */

/* A little reminder for those who, like me, only know the
do, re, mi... (Italian ?) names :
B si
A la
G sol
F fa
E mi
D re
C do */

#define T_b_3 T_UP_ONE_OCTAVE (T_b_2)
#define T_b_F_3 T_UP_ONE_OCTAVE (T_b_F_2)
#define T_a_S_3 T_b_F_3
#define T_a_3 T_UP_ONE_OCTAVE (T_a_2)
#define T_a_F_3 T_UP_ONE_OCTAVE (T_a_F_2)
#define T_g_S_3 T_a_F_3
#define T_g_3 T_UP_ONE_OCTAVE (T_g_2)
#define T_g_F_3 T_f_S_3
#define T_f_S_3 T_UP_ONE_OCTAVE (T_f_S_2)
#define T_f_3 T_UP_ONE_OCTAVE (T_f_2)
#define T_e_3 T_UP_ONE_OCTAVE (T_e_2)
#define T_e_F_3 T_UP_ONE_OCTAVE (T_e_F_2)
#define T_d_S_3 T_e_F_3
#define T_d_3 T_UP_ONE_OCTAVE (T_d_2)
#define T_d_F_3 T_c_S_3
#define T_c_S_3 T_UP_ONE_OCTAVE (T_c_S_2)
#define T_c_3 T_UP_ONE_OCTAVE (T_c_2)

#define B6      T_b_3
#define BF6     T_b_F_3
#define AS6     T_a_S_3
#define A6      T_a_3
#define AF6     T_a_F_3
#define GS6     T_g_S_3
#define G6      T_g_3
#define GF6     T_g_F_3
#define FS6     T_f_S_3
#define F6      T_f_3
#define E6      T_e_3
#define EF6     T_e_F_3
#define DS6     T_d_S_3
#define D6      T_d_3
#define DF6     T_d_F_3
#define CS6     T_c_S_3
#define C6      T_c_3

#define T_b_2 T_UP_ONE_OCTAVE (T_b_1)
#define T_b_F_2 T_UP_ONE_OCTAVE (T_b_F_1)
#define T_a_S_2 T_b_F_2
#define T_a_2 T_UP_ONE_OCTAVE (T_a_1)
#define T_a_F_2 T_UP_ONE_OCTAVE (T_a_F_1)
#define T_g_S_2 T_a_F_2
#define T_g_2 T_UP_ONE_OCTAVE (T_g_1)
#define T_g_F_2 T_f_S_2
#define T_f_S_2 T_UP_ONE_OCTAVE (T_f_S_1)
#define T_f_2 T_UP_ONE_OCTAVE (T_f_1)
#define T_e_2 T_UP_ONE_OCTAVE (T_e_1)
#define T_e_F_2 T_UP_ONE_OCTAVE (T_e_F_1)
#define T_d_S_2 T_e_F_2
#define T_d_2 T_UP_ONE_OCTAVE (T_d_1)
#define T_d_F_2 T_c_S_2
#define T_c_S_2 T_UP_ONE_OCTAVE (T_c_S_1)
#define T_c_2 T_UP_ONE_OCTAVE (T_c_1)

#define B5      T_b_2
#define BF5     T_b_F_2
#define AS5     T_a_S_2
#define A5      T_a_2
#define AF5     T_a_F_2
#define GS5     T_g_S_2
#define G5      T_g_2
#define GF5     T_g_F_2
#define FS5     T_f_S_2
#define F5      T_f_2
#define E5      T_e_2
#define EF5     T_e_F_2
#define DS5     T_d_S_2
#define D5      T_d_2
#define DF5     T_d_F_2
#define CS5     T_c_S_2
#define C5      T_c_2

#define T_b_1 T_UP_ONE_HALF (T_b_F_1)
#define T_b_F_1 T_UP_ONE_HALF (T_a_1)
#define T_a_S_1 T_b_F_1
#define T_a_1 ((short) (440))
#define T_a_F_1 T_DOWN_ONE_HALF (T_a_1)
#define T_g_S_1 T_a_F_1
#define T_g_1 T_DOWN_ONE_HALF (T_a_F_1)
#define T_g_F_1 T_f_S_1
#define T_f_S_1 T_DOWN_ONE_HALF (T_g_1)
#define T_f_1 T_DOWN_ONE_HALF (T_f_S_1)
#define T_e_1 T_DOWN_ONE_HALF (T_f_1)
#define T_e_F_1 T_DOWN_ONE_HALF (T_e_1)
#define T_d_S_1 T_e_F_1
#define T_d_1 T_DOWN_ONE_HALF (T_e_F_1)
#define T_d_F_1 T_c_S_1
#define T_c_S_1 T_DOWN_ONE_HALF (T_d_1)
#define T_c_1 T_DOWN_ONE_HALF (T_c_S_1)

#define B4      T_b_1
#define BF4     T_b_F_1
#define AS4     T_a_S_1
#define A4      T_a_1
#define AF4     T_a_F_1
#define GS4     T_g_S_1
#define G4      T_g_1
#define GF4     T_g_F_1
#define FS4     T_f_S_1
#define F4      T_f_1
#define E4      T_e_1
#define EF4     T_e_F_1
#define DS4     T_d_S_1
#define D4      T_d_1
#define DF4     T_d_F_1
#define CS4     T_c_S_1
#define C4      T_c_1

#define T_b T_DOWN_ONE_OCTAVE (T_b_1)
#define T_b_F T_DOWN_ONE_OCTAVE (T_b_F_1)
#define T_a_S T_b_F
#define T_a T_DOWN_ONE_OCTAVE (T_a_1)
#define T_a_F T_DOWN_ONE_OCTAVE (T_a_F_1)
#define T_g_S T_a_F
#define T_g T_DOWN_ONE_OCTAVE (T_g_1)
#define T_g_F T_f_S
#define T_f_S T_DOWN_ONE_OCTAVE (T_f_S_1)
#define T_f T_DOWN_ONE_OCTAVE (T_f_1)
#define T_e T_DOWN_ONE_OCTAVE (T_e_1)
#define T_e_F T_DOWN_ONE_OCTAVE (T_e_F_1)
#define T_d_S T_e_F
#define T_d T_DOWN_ONE_OCTAVE (T_d_1)
#define T_d_F T_c_S
#define T_c_S T_DOWN_ONE_OCTAVE (T_c_S_1)
#define T_c T_DOWN_ONE_OCTAVE (T_c_1)

#define B3      T_b
#define BF3     T_b_F
#define AS3     T_a_S
#define A3      T_a
#define AF3     T_a_F
#define GS3     T_g_S
#define G3      T_g
#define GF3     T_g_F
#define FS3     T_f_S
#define F3      T_f
#define E3      T_e
#define EF3     T_e_F
#define DS3     T_d_S
#define D3      T_d
#define DF3     T_d_F
#define CS3     T_c_S
#define C3      T_c

#define T_b_0 T_DOWN_ONE_OCTAVE (T_b)
#define T_b_F_0 T_DOWN_ONE_OCTAVE (T_b_F)
#define T_a_S_0 T_b_F_0
#define T_a_0 T_DOWN_ONE_OCTAVE (T_a)
#define T_a_F_0 T_DOWN_ONE_OCTAVE (T_a_F)
#define T_g_S_0 T_a_F_0
#define T_g_0 T_DOWN_ONE_OCTAVE (T_g)
#define T_g_F_0 T_f_S_0
#define T_f_S_0 T_DOWN_ONE_OCTAVE (T_f_S)
#define T_f_0 T_DOWN_ONE_OCTAVE (T_f)
#define T_e_0 T_DOWN_ONE_OCTAVE (T_e)
#define T_e_F_0 T_DOWN_ONE_OCTAVE (T_e_F)
#define T_d_S_0 T_e_F_0
#define T_d_0 T_DOWN_ONE_OCTAVE (T_d)
#define T_d_F_0 T_c_S_0
#define T_c_S_0 T_DOWN_ONE_OCTAVE (T_c_S)
#define T_c_0 T_DOWN_ONE_OCTAVE (T_c)

#define B2      T_b_0
#define BF2     T_b_F_0
#define AS2     T_a_S_0
#define A2      T_a_0
#define AF2     T_a_F_0
#define GS2     T_g_S_0
#define G2      T_g_0
#define GF2     T_g_F_0
#define FS2     T_f_S_0
#define F2      T_f_0
#define E2      T_e_0
#define EF2     T_e_F_0
#define DS2     T_d_S_0
#define D2      T_d_0
#define DF2     T_d_F_0
#define CS2     T_c_S_0
#define C2      T_c_0

struct note
{
short pitch;
short duration;
};

struct melody
{
char *name;
int measure;
struct note *next;
struct note note[];
};

struct melody tune1 =

  { "FSF_Song", 160, NULL, {
    /* The Free Software Song.  Measure: 7/4.  */
    { T_d_2, 16 }, { T_c_2,  8 }, { T_b_1, 16 }, { T_a_1, 16 },
    { T_b_1, 16 }, { T_c_2,  8 }, { T_b_1,  8 }, { T_a_1,  8 }, { T_g_1, 16 },
    { T_g_1, 24 }, { T_a_1, 24 }, { T_b_1,  8 },
    { T_c_2, 24 }, { T_b_1, 14 }, { T_REST, 2 }, { T_b_1,  8 }, { T_d_2, 8 },
    { T_a_1, 22 }, { T_REST, 2 }, { T_a_1, 32 },
    { T_c_2, 16 }, { T_d_2,  8 }, { T_c_2, 16 }, { T_b_1, 24 },
    { T_d_2, 16 }, { T_c_2,  8 }, { T_b_1, 16 }, { T_a_1, 16 },
    { T_b_1, 16 }, { T_c_2,  8 }, { T_b_1,  8 }, { T_a_1,  8 }, { T_g_1, 16 },
    { T_g_1, 24 }, { T_a_1, 24 }, { T_b_1,  8 },
    { T_c_2, 24 }, { T_b_1, 14 }, { T_REST, 2 }, { T_b_1,  8 }, { T_d_2, 8 },
    { T_a_1, 22 }, { T_REST, 2 }, { T_a_1, 30 }, { T_REST, 2 },
    { T_a_1, 56 }, { T_FINE, 0 }

} };

struct melody tune2 =

  { "I_Feel_Pretty", 160, NULL, {
    /* I feel pretty.  Measure: 3/4.  By Leonard Bernstein.  */
    { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 20 },
    { T_REST, 8 }, { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 20 },
    { T_REST, 8 }, { T_c_1,  8 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 12 }, { T_e_1,  8 },
    { T_f_1,  4 }, { T_a_1, 12 }, { T_f_1,  8 },
    { T_c_2, 32 },
    { T_b_F_1,8 }, { T_a_1,  8 },
    { T_g_1,  4 }, { T_f_1, 20 },
    { T_REST, 8 }, { T_g_1,  8 }, { T_a_1,  8 },
    { T_b_F_1,12}, { T_a_1,  4 }, { T_g_1,  4 }, { T_f_1, 4 },
    { T_e_1, 16 }, { T_d_1,  3 }, { T_e_1,  2 }, { T_d_1, 3 },
    { T_c_1, 56 }, { T_FINE, 0 }

} };

struct melody tune3 =

  { "Summertime", 120, NULL, {
    /* Summertime.  Measure: 4/4.  By George & Ira Gershwin.  */
    { T_b_1,  8 }, { T_g_1,  8 },
    { T_b_1, 36 }, { T_REST, 4 }, { T_a_1,  6 }, { T_g_1,  2 },
    { T_a_1,  6 }, { T_b_1,  2 }, { T_g_1,  8 },
    { T_e_1, 16 }, { T_b,   24 }, { T_REST, 8 },
    { T_b_1,  8 }, { T_g_1,  8 },
    { T_a_1,  3 }, { T_REST, 1 }, { T_a_1, 28 },
    { T_REST, 8 }, { T_g_1,  6 }, { T_e_1,  2 },
    { T_g_1,  6 }, { T_e_1,  2 }, { T_g_1,  8 },
    { T_f_S_1,48}, { T_REST, 4 }, { T_b_1,  8 }, { T_g_1,  4 },
    { T_b_1,  3 }, { T_REST, 1 }, { T_b_1,  7 }, { T_REST, 1 }, { T_b_1, 20 },
    { T_REST, 8 }, { T_a_1,  6 }, { T_g_1,  2 },
    { T_a_1,  6 }, { T_b_1,  2 }, { T_g_1,  8 },
    { T_e_1, 16 }, { T_b,   32 }, { T_REST, 8 },
    { T_b,    8 }, { T_d_1,  8 }, { T_b,    4 },
    { T_d_1,  4 }, { T_e_1,  8 }, { T_g_1,  8 },
    /* Keen attempt at a glissando.  */
    { T_b_1,  2 }, { T_b_1 + (T_b_1 - T_a_1) / 3, 1 },
    { T_b_1 + 2 * (T_b_1 - T_a_1) / 3, 1 },
    { T_a_1, 12 }, { T_g_1, 15 }, { T_REST,  1 },
    { T_g_1,  4 }, { T_e_1, 68 },
    { T_FINE, 0 }

} };

struct melody tune4 =

  { "Indiana_Jones_Theme", 250, NULL, {
    /* Indiana Jones Theme.  Measure: 4/4.  By John Williams.  */
    { T_e_1, 4 }, { T_REST, 8 }, { T_f_1, 4 },
    { T_g_1, 4 }, { T_REST, 4 }, { T_c_2, 24 },
    { T_REST, 16 }, { T_d_1, 4 }, { T_REST, 8 }, { T_e_1, 4 },
    { T_f_1, 32 },
    { T_REST, 16 }, { T_g_1, 4 }, { T_REST, 8 }, { T_a_1, 4 },
    { T_b_1, 4 }, { T_REST, 4 }, { T_f_2, 24 },
    { T_REST, 16 }, { T_a_1, 4 }, { T_REST, 8 }, { T_b_1, 4 },
    { T_c_2, 8 }, { T_REST, 8 }, { T_d_2, 12 }, { T_REST, 4 },
    { T_e_2, 8 }, { T_REST, 8 },
    { T_e_1, 4 }, { T_REST, 8 }, { T_f_1, 4 },
    { T_g_1, 4 }, { T_REST, 4 }, { T_c_2, 24 },
    { T_REST, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_e_2, 4 },
    { T_f_2, 32 },
    { T_REST, 16 }, { T_g_1, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_e_2, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_e_2, 16 }, { T_d_2, 4 }, { T_REST, 8 }, { T_g_1, 4 },
    { T_f_2, 16 }, { T_e_2, 4 }, { T_REST, 8 }, { T_d_2, 4 },
    { T_c_2, 32 }, { T_FINE, 0 }

} };

struct melody tune5 =

  { "Beverly_Hills_Cop.", 600, NULL, {
    /* Axel F, soundtrack of Beverly Hills Cop.  By Harold
       Faltermeyer, composed by Frank Jr.  ([email protected]).  */
    {  T_e_1,  8 }, { T_REST, 16 }, {  T_g_1,  6 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_e_1,  4 }, { T_REST,  8 }, {  T_e_1,  5 },
    { T_REST,  2 }, {  T_a_1,  5 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  8 }, {  T_d_1,  5 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  8 }, { T_REST, 16 }, {  T_b_1,  6 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_e_1,  6 }, { T_REST,  8 }, {  T_e_1,  6 },
    { T_REST,  2 }, {  T_c_2,  4 }, { T_REST,  8 }, {  T_b_1,  5 },
    { T_REST,  8 }, {  T_g_1,  3 }, { T_REST,  4 }, { T_REST,  8 },
    {  T_e_1,  3 }, { T_REST,  4 }, { T_REST,  8 }, {  T_b_1,  3 },
    { T_REST,  4 }, { T_REST,  8 }, {  T_e_2,  4 }, { T_REST,  8 },
    {  T_e_1,  3 }, { T_REST,  4 }, {  T_d_1,  5 }, { T_REST,  8 },
    {  T_d_1,  5 }, {    T_a,  4 }, { T_REST,  4 }, { T_REST,  8 },
    {  T_f_1, 12 }, { T_REST,  4 }, {  T_e_1, 92 }, { T_REST, 16 },
    { T_REST, 32 }, { T_FINE,  0 }

} };

struct melody tune6 =

  { "Star_Trek:_The_Next_Generation", 600, NULL, {
    /* Music from the `Star Trek: The Next Generation' episode `Inner
       Light'.  Composed by Jay Chattaway.  */
    {  T_f_1, 64 }, { T_REST, 16 }, {  T_g_1, 32 }, { T_REST,  8 },
    {  T_f_1, 42 }, { T_REST,  8 }, { T_REST,  8 }, {  T_b_1, 64 },
    { T_REST,  8 }, { T_REST, 16 }, { T_REST,  8 }, {  T_b_1, 42 },
    { T_REST,  8 }, { T_REST,  8 }, {  T_c_2, 64 }, { T_REST,  8 },
    { T_REST, 16 }, {  T_f_2, 42 }, { T_REST,  8 }, {  T_e_2, 85 },
    { T_REST,  8 }, { T_REST, 16 }, {  T_c_2, 64 }, { T_REST, 16 },
    {  T_g_2, 42 }, { T_REST,  8 }, {  T_f_2, 64 }, { T_REST,  8 },
    { T_REST,  8 }, {  T_f_1, 42 }, { T_REST,  8 }, {  T_e_2, 64 },
    {  T_c_2, 21 }, { T_REST,  8 }, {  T_b_1, 42 }, { T_REST,  8 },
    {  T_g_1, 85 }, { T_FINE,  0 }

} };

struct melody tune99 =

  { "Tetris_Theme", 300, NULL, {
    /* Generated reading a midi partition. Most known Tetris theme tune.  */
    {     E5, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5,  8 },
      {     E5,  4 }, {     D5,  4 }, {     C5,  8 }, {     B4,  8 },
    {     A4, 16 }, {     A4,  8 }, {     C5,  8 }, {     E5, 16 },
      {     D5,  8 }, {     C5,  8 },
    {     B4, 24 }, {     C5,  8 }, {     D5, 16 }, {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 32 },
    { T_REST,  8 }, {     D5, 16 }, {     F5,  8 }, {     A6, 16 },
      {     G5,  8 }, {     F5,  8 },
    {     E5, 24 }, {     C5,  8 }, {     E5, 16 }, {     D5,  8 },
      {     C5,  8 },
    {     B4, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5, 16 },
      {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 16 }, { T_REST, 16 },
    {     E5, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5,  8 },
      {     E5,  4 }, {     D5,  4 }, {     C5,  8 }, {     B4,  8 },
    {     A4, 16 }, {     A4,  8 }, {     C5,  8 }, {     E5, 16 },
      {     D5,  8 }, {     C5,  8 },
    {     B4, 24 }, {     C5,  8 }, {     D5, 16 }, {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 32 },
    { T_REST,  8 }, {     D5, 16 }, {     F5,  8 }, {     A6, 16 },
      {     G5,  8 }, {     F5,  8 },
    {     E5, 24 }, {     C5,  8 }, {     E5, 16 }, {     D5,  8 },
      {     C5,  8 },
    {     B4, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5, 16 },
      {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 16 }, { T_REST, 16 },
    {     E4, 32 }, {     C4, 32 },
    {     D4, 32 }, {     B3, 32 },
    {     C4, 32 }, {     A3, 32 },
    {    GF2, 32 }, {     B3, 16 }, { T_REST, 16 },
    {     E4, 32 }, {     C4, 32 },
    {     D4, 32 }, {     B3, 32 },
    {     C4, 16 }, {     E4, 16 }, {     A4, 32 },
    {    GS4, 32 }, { T_REST, 16 }, { T_REST, 16 },
    {     E5, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5,  8 },
      {     E5,  4 }, {     D5,  4 }, {     C5,  8 }, {     B4,  8 },
    {     A4, 16 }, {     A4,  8 }, {     C5,  8 }, {     E5, 16 },
      {     D5,  8 }, {     C5,  8 },
    {     B4, 24 }, {     C5,  8 }, {     D5, 16 }, {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 32 },
    { T_REST,  8 }, {     D5, 16 }, {     F5,  8 }, {     A6, 16 },
      {     G5,  8 }, {     F5,  8 },
    {     E5, 24 }, {     C5,  8 }, {     E5, 16 }, {     D5,  8 },
      {     C5,  8 },
    {     B4, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5, 16 },
      {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 16 }, { T_REST, 16 },
    {     E5, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5,  8 },
      {     E5,  4 }, {     D5,  4 }, {     C5,  8 }, {     B4,  8 },
    {     A4, 16 }, {     A4,  8 }, {     C5,  8 }, {     E5, 16 },
      {     D5,  8 }, {     C5,  8 },
    {     B4, 24 }, {     C5,  8 }, {     D5, 16 }, {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 32 },
    { T_REST,  8 }, {     D5, 16 }, {     F5,  8 }, {     A6, 16 },
      {     G5,  8 }, {     F5,  8 },
    {     E5, 24 }, {     C5,  8 }, {     E5, 16 }, {     D5,  8 },
      {     C5,  8 },
    {     B4, 16 }, {     B4,  8 }, {     C5,  8 }, {     D5, 16 },
      {     E5, 16 },
    {     C5, 16 }, {     A4, 16 }, {     A4, 16 }, { T_REST, 16 },
    { T_FINE,  0 }

} };

struct melody *tune[] = { &tune1, &tune2, &tune3, &tune4, &tune5, &tune6, &tune99 };

int main(void)
{
int a,b;
FILE *f;
for ( a = 0; a < sizeof (tune) / sizeof (tune[0]); a++)

    {
      b = 0;
      printf ("Number : %i\n", a);
      f = fopen (tune[a]->name, "w");
      fprintf (f, "%c%c%c%c",
               tune[a]->measure & 0xFF,
               tune[a]->measure >> 8 & 0xFF,
               tune[a]->measure >> 16 & 0xFF,
               tune[a]->measure >> 24 & 0xFF);
      while (tune[a]->note[b].pitch != T_FINE)
        {
          fprintf (f, "%c%c%c%c",
                   tune[a]->note[b].pitch & 0xFF,tune[a]->note[b].pitch >> 8 & 0xFF,
                   tune[a]->note[b].duration & 0xFF,tune[a]->note[b].duration >> 8 & 0xFF);
          b++;
        }
      fclose (f);
    }
}
#5 lore raw
In reply to Marco Gerards
Quoted 7 lines · Marco Gerards
Quoted 5 lines

Here is the source of a little tool to generate tunes for Grub 2 play command.
Quick coded, could be more powerful but I'm not sure it's worth the work.

I'm not sure if it should enter the cvs, too. And if it does, where ?

Perhaps `contrib/util/i386/' or so?

Nope. Please use the directory util for any utility. For the module, please create a new directory. I prefer "fun" to "contrib", as that is more explicit.

Okuji

#6 lore raw
Quoted 5 lines · Yoshinori K. Okuji
Quoted 4 lines · Marco Gerards
Quoted 4 lines

Here is the source of a little tool to generate tunes for Grub 2 play command.
Quick coded, could be more powerful but I'm not sure it's worth the work.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I'm not sure if it should enter the cvs, too. And if it does, where ?

Perhaps `contrib/util/i386/' or so?

Nope. Please use the directory util for any utility. For the module, please create a new directory. I prefer "fun" to "contrib", as that is more explicit.

Right, but what if we want to add contirubted modules that have a serious use, for example? Things that are useful but can/will not added to the rest of GRUB 2.

--
Marco

#7 lore raw
Quoted 3 lines · Marco Gerards

Right, but what if we want to add contirubted modules that have a serious use, for example? Things that are useful but can/will not added to the rest of GRUB 2.

Why cannot they be added? Modules should be categorized according to their functions. Can you give me an example?

Okuji

#8 lore raw
Quoted 7 lines · Yoshinori K. Okuji
Quoted 3 lines · Marco Gerards

Right, but what if we want to add contirubted modules that have a serious use, for example? Things that are useful but can/will not added to the rest of GRUB 2.

Why cannot they be added? Modules should be categorized according to their functions. Can you give me an example?

Something that uses code from another project perhaps? Or something that does not fit cleanly in the rest of GRUB or so. Perhaps a SCSI driver or so. If you think everything can go into the main directory of GRUB 2, having fun/ is not a problem for me.

--
Marco