create programs for song words

  • 28 Replies
  • 11511 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Make it Lady

  • Neilep Level Member
  • ******
  • 4050
  • Hands-on fun for everyone!
    • View Profile
create programs for song words
« on: 08/02/2009 00:09:19 »
Here is a challenge. My son wrote a program for "if your happy and you know it clap your hands. it went something like this (I'm not a geek so this may not be quite right.)

If happy=1 and know it=1 then clap hands.

Now it is your turn. Think of a song and write an appropriate program. 
Give a man a fire and he is warm for a day, set a man on fire and he is warm for the rest of his life.

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #1 on: 08/02/2009 00:36:12 »
If 'happy' and 'know_it' were defined as bools you'd only need to to say:

if(happy && know_it) {clap hands};
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile

*

Offline Vern

  • Neilep Level Member
  • ******
  • 2072
    • View Profile
    • Photonics
create programs for song words
« Reply #3 on: 08/02/2009 16:58:22 »
If 'happy' and 'know_it' were defined as bools you'd only need to to say:

if(happy && know_it) {clap hands};

LeeE speak C; Make it Lady speak Basic [:)]

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #4 on: 08/02/2009 22:10:14 »
Is there such a thing as a 'basic' woman?  They all seem to be unique.
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #5 on: 18/02/2009 17:34:39 »
10 LET N$=" green bottles standing on a wall,"
20 LET F$="and if 1 green bottle should accident'ly fall,"
30 LET W$="1 green bottle standing on a wall,"   
40 FOR x = 100 TO 2 STEP -1
50 PRINT x;N$,x;N$,F$
60 IF x > 2 THEN PRINT "there'd be ";(x-1);" green bottles standing on a wall."
     ELSE PRINT "there'd be 1 green bottle standing on a wall."
70 NEXT x
80 PRINT W$,W$,F$
90 PRINT “there’d be no green bottles sitting on a wall.”
« Last Edit: 18/02/2009 17:38:57 by RD »

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #6 on: 20/02/2009 16:27:18 »
At line No. 40 you're starting the loop index at 100 - I think most people get fed up with singing it after just the more usual 10 verses  [;)]

Could I suggest this re-write?

100 LET B$=" green bottle"
110 LET W$="standing on a wall"
120 LET F$="and if 1 green bottle should accidentally fall,"
130 LET T$="there'd be "
140 FOR x = 10 TO 1 STEP -1
150   IF x = 1 THEN LET S$=" " ELSE LET S$="s "
160   FOR y = 0 to 1
170     PRINT x;B$;S$;W$
180   NEXT y
190   IF x-1 = 1 THEN LET S$=" " ELSE LET S$="s "
200   PRINT F$
210   PRINT T$;x-1;B$;S$;W$
220 NEXT x

I should point out that I haven't tested this code - lol.

Perhaps there should be a test to see how many bottles there actually are on the wall, but as the song only speaks of 'if one should fall' I guess it's all hypothetical. [:)]
« Last Edit: 20/02/2009 17:04:24 by LeeE »
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #7 on: 20/02/2009 18:11:03 »
At line No. 40 you're starting the loop index at 100 - I think most people get fed up with singing it after just the more usual 10 verses  [;)]

Could I suggest this re-write?

100 LET B$=" green bottle"
110 LET W$="standing on a wall"
120 LET F$="and if 1 green bottle should accidentally fall,"
130 LET T$="there'd be "
140 FOR x = 10 TO 1 STEP -1
150   IF x = 1 THEN LET S$=" " ELSE LET S$="s "
160   FOR y = 0 to 1
170     PRINT x;B$;S$;W$
180   NEXT y
190   IF x-1 = 1 THEN LET S$=" " ELSE LET S$="s "
200   PRINT F$
210   PRINT T$;x-1;B$;S$;W$
220 NEXT x

I should point out that I haven't tested this code - lol.

You've dealt with the singular/plural problem in a more elegant way than I have, others have not noticed this problem ...

Quote
"There'll be one green bottles" [sic]
http://www.kididdles.com/lyrics/t050.html
(no wonder the kididdles are increasingly inarticulate). 

However your program will print "There'd be 0 green bottles...", when the lyric is "There'd be no green bottles...",
"0" could be pronounced "oh", "zero" or "nought".

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #8 on: 20/02/2009 23:21:12 »
Is using BASIC a pre-requisite?

Just had a silly thought - write it in COBOL!  [:D]
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #9 on: 21/02/2009 02:38:37 »
10 PRINT " © John Cage "
20 PAUSE 27300 : REM centiseconds
30 PRINT " FINISHED "

http://news.bbc.co.uk/1/hi/entertainment/music/2276621.stm

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #10 on: 21/02/2009 03:02:54 »
10 PRINT " © John Cage "
20 PAUSE 27300 : REM centiseconds
30 PRINT " FINISHED "

Very good
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #11 on: 21/02/2009 18:04:48 »
Quote
However your program will print "There'd be 0 green bottles...", when the lyric is "There'd be no green bottles...",
"0" could be pronounced "oh", "zero" or "nought".

Heh - the two are synonymous to me;)  Zero is a complete absence of i.e. none, or in this lexical context, no.

But a reasonable point.
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #12 on: 21/02/2009 18:42:23 »
Quote
However your program will print "There'd be 0 green bottles...", when the lyric is "There'd be no green bottles...",
"0" could be pronounced "oh", "zero" or "nought".

Heh - the two are synonymous to me;)  Zero is a complete absence of i.e. none, or in this lexical context, no.

But a reasonable point.

This is "Geek Speak": (my) nitpicking is an essential characteristic of geekiness.

*

Offline Make it Lady

  • Neilep Level Member
  • ******
  • 4050
  • Hands-on fun for everyone!
    • View Profile
create programs for song words
« Reply #13 on: 21/02/2009 21:52:54 »
I am disallowing COBOL as I don't understand it. You can do C++ if you like as my son is learning this at the moment and he will appreciate it. I'm glad you are enjoying this. It was murray's idea. He is geek lord.
Give a man a fire and he is warm for a day, set a man on fire and he is warm for the rest of his life.

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #14 on: 21/02/2009 22:43:42 »
You wouldn't OBJECT to C++?  [:D]
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #15 on: 22/02/2009 15:00:24 »
if(minutes == 0) {rock_around_the_clock()};
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #16 on: 22/02/2009 19:35:45 »
if(minutes == 0) {rock_around_the_clock()};

Now let's see the rock_around_the_clock() function
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline neilep

  • Withdrawnmist
  • Naked Science Forum GOD!
  • *******
  • 20602
    • View Profile
create programs for song words
« Reply #17 on: 22/02/2009 22:16:09 »
I'm so proud to announce that I do not understand a thing in this thread.


...and that makes me happy !....blissfull even !!
Men are the same as women, just inside out !

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #18 on: 23/02/2009 01:20:18 »
if ($neilep_understands){
    echo "YAY";
}
else{
    echo "BOO";
    die($_PHP_ERROR);
}
« Last Edit: 23/02/2009 01:22:48 by DoctorBeaver »
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #19 on: 23/02/2009 03:09:30 »
 90 REM pop lyric generator
100 DIM A$(7)
110 LET A$(1) = "baby"
120 LET A$(2) = "love"
130 LET A$(3) = "ooh"
140 LET A$(4) = "aah"
150 LET A$(5) = "you"
160 LET A$(6) = "me"
170 LET A$(7) = "good"
180 FOR L=1 TO 12: REM 12 lines in song
190  LET W=INT(RND(9)+1): REM up to 10 words per line
200   FOR F=1 TO W
210    LET N=INT (RND(6)+1)
220    PRINT A$(N);" ";
230   NEXT F
240  PRINT: REM newline
250 NEXT L
260 PRINT " Eurovision Winner  ;-) "
« Last Edit: 24/02/2009 02:31:26 by RD »

*

Offline Make it Lady

  • Neilep Level Member
  • ******
  • 4050
  • Hands-on fun for everyone!
    • View Profile
create programs for song words
« Reply #20 on: 23/02/2009 16:44:08 »
You could make a million with that RD. I read recently that most of the top pop anthems use the same four chords. Beaver might be able to enlighten us on which ones they are. Perhaps we could combine RDs program with a similar one for chords and we could have an international number 1 hit.
Give a man a fire and he is warm for a day, set a man on fire and he is warm for the rest of his life.

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #21 on: 23/02/2009 19:29:11 »
Most commonly they would be the root major,the 4th major, 5th major and 6th minor (e.g. Cmaj, Fmaj, Gmaj, Amin). An alternative would be root major, 4th major, 5th major, and 7th major or 7th major with a minor 7th (in case that sounds confusing, a major chord with a minor 7th would be, for instance, the chord of Dmaj with the note of C added which is the 7th of the Dmin mode). At least, that would hold true for most upbeat songs. Ballads are often written in a minor mode in which case the root would be a minor chord and the others either major or minor. In some cases, for a major mode, the 4th major is sometimes replaced by the 7th minor.

However, many songs use only the root, 4th & 5th (e.g. 12-bar blues).

I though, being an awkward bugger, use silly chords such as Em9/6 (E minor chord with a minor ninth and an added 6th) or Em7+9 (E minor 7th with an augmented 9th). Maybe that's why I've never had a hit record  [:(]
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline RD

  • Neilep Level Member
  • ******
  • 8185
    • View Profile
create programs for song words
« Reply #22 on: 23/02/2009 19:39:03 »
Software is already used to "predict" pop music hits ...

Quote
The Guardian, Monday 17 January 2005
 
...a piece of software that can "predict" the chance of a track being a hit or a miss. This computerised equivalent of the television programmer Juke Box Jury is known as Hit Song Science (HSS). It has been developed by a Spanish company, Polyphonic HMI, which used decades of experience developing artificial intelligence technology for the banking and telecoms industries to create a program that analysed the underlying mathematical patterns in music. It isolated and separated 20 aspects of song construction including melody, harmony, chord progression, beat, tempo and pitch and identifies and maps recurrent patterns in a song, before matching it against a database containing 30 years' worth of Billboard hit singles - 3.5m tunes in all. The program then accords the song a score, which registers, in effect, the likelihood of it being a chart success.
http://www.guardian.co.uk/music/2005/jan/17/popandrock
« Last Edit: 23/02/2009 19:49:45 by RD »

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #23 on: 23/02/2009 19:42:17 »
if(minutes == 0) {rock_around_the_clock()};

Now let's see the rock_around_the_clock() function

Actually, the function should probably just be called rock(), but yes, this function is going to be a bit more complex.  Hmm...  howzabout...

if(minutes == 0) rock(hour);

static void rock(int hr) {
  if(hr == 1 ) {
    printf("Put your glad rags on and join me, hon");
  } else if((hr >= 2) && (hr <= 4)) {
    if(band_speed < prev_band_speed) {
      printf("yell for more");
    }
  } else if((hr >= 5) && (hr <= 7)) {
    printf("We'll be right in seventh heaven")
  } else if((hr >= 8) && (hr <= 11)) {
    printf("I'll be goin'' strong and so will you");
  } else if(hr == 12) {
    cool_off();
  }
}

There are probably quite a few syntax errors in there - lol - it's been a while since I did any coding and I may have mixed C & C++ syntax incorrectly with other languages I've used (where's the syntax checker when you need it?)

And no, I'm not going to code the function cool_off() - it's too subjective  [;)]

P.S.  Oops - just realised that I'm not passing band_speed and prev_band_speed to the func
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #24 on: 23/02/2009 19:50:22 »
LeeE - On the whole, not a bad effort. 7/10
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline LeeE

  • Neilep Level Member
  • ******
  • 3382
    • View Profile
    • Spatial
create programs for song words
« Reply #25 on: 23/02/2009 20:46:01 »
 [;D]
...And its claws are as big as cups, and for some reason it's got a tremendous fear of stamps! And Mrs Doyle was telling me it's got magnets on its tail, so if you're made out of metal it can attach itself to you! And instead of a mouth it's got four arses!

*

Offline Chemistry4me

  • Neilep Level Member
  • ******
  • 7709
    • View Profile
create programs for song words
« Reply #26 on: 24/02/2009 07:39:45 »
if(minutes == 0) rock(hour);

static void rock(int hr) {
  if(hr == 1 ) {
    printf("Put your glad rags on and join me, hon");
  } else if((hr >= 2) && (hr <= 4)) {
    if(band_speed < prev_band_speed) {
      printf("yell for more");
    }
  } else if((hr >= 5) && (hr <= 7)) {
    printf("We'll be right in seventh heaven")
  } else if((hr >= 8) && (hr <= 11)) {
    printf("I'll be goin'' strong and so will you");
  } else if(hr == 12) {
    cool_off();
  }
}

There are probably quite a few syntax errors in there - lol - it's been a while since I did any coding and I may have mixed C & C++ syntax incorrectly with other languages I've used (where's the syntax checker when you need it?)

And no, I'm not going to code the function cool_off() - it's too subjective  [;)]

P.S.  Oops - just realised that I'm not passing band_speed and prev_band_speed to the func
You might as well be speaking Mongolian for all I know! [:o][:o] [???][???][???]

*

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • 12656
  • A stitch in time would have confused Einstein.
    • View Profile
create programs for song words
« Reply #27 on: 24/02/2009 10:19:57 »
Mongolian doesn't have so many consonants  [:D]
Fledgling science site at http://www.sciencefile.org/SF/content/view/54/98/ needs members and original articles. If you can help, please join.

*

Offline Chemistry4me

  • Neilep Level Member
  • ******
  • 7709
    • View Profile
create programs for song words
« Reply #28 on: 25/02/2009 04:31:14 »
Ah... well, there you are, thank you for proving my point!