Skip to main content
Mod Removes Wiki by Martin EnderMod
Post Made Community Wiki by Martin EnderMod
Post Merged (destination) from meta.codegolf.stackexchange.com/questions/1847/…
Post Merged (destination) from meta.codegolf.stackexchange.com/questions/735/…
added 224 characters in body
Source Link
PhiNotPi
  • 29.3k
  • 2
  • 39
  • 46

Digital Music Box

What are holidays without music boxes?

Your task is to implement a digital music box. Your program will be given a reel of music such as follows:

Music from "The Polar Express" By Glen Ballard and Alan Silvestri 120 lines per minute CDEFGABCDEFGABC ............... ..O.O..O....... ............... .......O.O.O... ............... ..O.O.O........ ............... ......O..O.O... ............... CDEFGABCDEFGABC O.O....O....... .O......O...... ..O......O..... ....O.......... ..O.O.O........ ............... ..O.O.......... ............... 

Now, your program must play the music, which is straightforward. In this example, one line is read every 1/2 second. If a line contains one or more O characters, those notenotes are played simultaneously to form a chord.

The range of the music box is a Concert C scale from Middle C (C4) on the left to High C (C6) on the right.

When a chord is played, the sounds of all previous chords are stopped. If a line does not contain any notes, then the previous chord is sustained at reduced volume.

Input

Input will be several lines of text. Your program should read and follow the directions line-by-line.

If a line contains ### lines per minute then each following line of music should be played at that tempo. There may be more than one tempo change in the piece, and your program should be able to change tempos. The tempo change itself does not take up any time. There will always be a tempo mark before any music lines.

If a line contains music (15 characters long, all characters either . or O), then those notes should be played and sustained for the correct duration (given by the tempo).

If a line does not fall into either of the above categories (like Music from... and CDEFG... in the above example), then it should be ignored completely. The program should act as if they weren't there, simply skip over them with no pause.

Output

Output could either be sound from the speakers, or a playable .MP3 or .WAV music file.

QUESTIONS

Should this be code golf? I assume so, although I want an added bonus for improvedalthough I want an added bonus for improved sound quality. It's probably not going to be possible to enforce sound quality requirements.

Are there any other things to add? Or, is this pretty much ready to go?

Digital Music Box

What are holidays without music boxes?

Your task is to implement a digital music box. Your program will be given reel of music such as follows:

Music from "The Polar Express" By Glen Ballard and Alan Silvestri 120 lines per minute CDEFGABCDEFGABC ............... ..O.O..O....... ............... .......O.O.O... ............... ..O.O.O........ ............... ......O..O.O... ............... CDEFGABCDEFGABC O.O....O....... .O......O...... ..O......O..... ....O.......... ..O.O.O........ ............... ..O.O.......... ............... 

Now, your program must play the music, which is straightforward. In this example, one line is read every 1/2 second. If a line contains one or more O characters, those note are played simultaneously to form a chord.

The range of the music box is a Concert C scale from Middle C (C4) on the left to High C (C6) on the right.

When a chord is played, the sounds of all previous chords are stopped. If a line does not contain any notes, then the previous chord is sustained at reduced volume.

Input

Input will be several lines of text. Your program should read and follow the directions line-by-line.

If a line contains ### lines per minute then each following line of music should be played at that tempo. There may be more than one tempo change in the piece, and your program should be able to change tempos. The tempo change itself does not take up any time.

If a line contains music (15 characters long, all characters either . or O), then those notes should be played and sustained for the correct duration (given by the tempo).

If a line does not fall into either of the above categories (like Music from... and CDEFG... in the above example), then it should be ignored completely. The program should act as if they weren't there, simply skip over them with no pause.

Output

Output could either be sound from the speakers, or a playable .MP3 or .WAV music file.

QUESTIONS

Should this be code golf? I assume so, although I want an added bonus for improved sound quality.

Digital Music Box

What are holidays without music boxes?

Your task is to implement a digital music box. Your program will be given a reel of music such as follows:

Music from "The Polar Express" By Glen Ballard and Alan Silvestri 120 lines per minute CDEFGABCDEFGABC ............... ..O.O..O....... ............... .......O.O.O... ............... ..O.O.O........ ............... ......O..O.O... ............... CDEFGABCDEFGABC O.O....O....... .O......O...... ..O......O..... ....O.......... ..O.O.O........ ............... ..O.O.......... ............... 

Now, your program must play the music, which is straightforward. In this example, one line is read every 1/2 second. If a line contains one or more O characters, those notes are played simultaneously to form a chord.

The range of the music box is a Concert C scale from Middle C (C4) on the left to High C (C6) on the right.

When a chord is played, the sounds of all previous chords are stopped. If a line does not contain any notes, then the previous chord is sustained at reduced volume.

Input

Input will be several lines of text. Your program should read and follow the directions line-by-line.

If a line contains ### lines per minute then each following line of music should be played at that tempo. There may be more than one tempo change in the piece, and your program should be able to change tempos. The tempo change itself does not take up any time. There will always be a tempo mark before any music lines.

If a line contains music (15 characters long, all characters either . or O), then those notes should be played and sustained for the correct duration (given by the tempo).

If a line does not fall into either of the above categories (like Music from... and CDEFG... in the above example), then it should be ignored completely. The program should act as if they weren't there, simply skip over them with no pause.

Output

Output could either be sound from the speakers, or a playable .MP3 or .WAV music file.

QUESTIONS

Should this be code golf? I assume so, although I want an added bonus for improved sound quality. It's probably not going to be possible to enforce sound quality requirements.

Are there any other things to add? Or, is this pretty much ready to go?

Source Link
PhiNotPi
  • 29.3k
  • 2
  • 39
  • 46

Digital Music Box

What are holidays without music boxes?

Your task is to implement a digital music box. Your program will be given reel of music such as follows:

Music from "The Polar Express" By Glen Ballard and Alan Silvestri 120 lines per minute CDEFGABCDEFGABC ............... ..O.O..O....... ............... .......O.O.O... ............... ..O.O.O........ ............... ......O..O.O... ............... CDEFGABCDEFGABC O.O....O....... .O......O...... ..O......O..... ....O.......... ..O.O.O........ ............... ..O.O.......... ............... 

Now, your program must play the music, which is straightforward. In this example, one line is read every 1/2 second. If a line contains one or more O characters, those note are played simultaneously to form a chord.

The range of the music box is a Concert C scale from Middle C (C4) on the left to High C (C6) on the right.

When a chord is played, the sounds of all previous chords are stopped. If a line does not contain any notes, then the previous chord is sustained at reduced volume.

Input

Input will be several lines of text. Your program should read and follow the directions line-by-line.

If a line contains ### lines per minute then each following line of music should be played at that tempo. There may be more than one tempo change in the piece, and your program should be able to change tempos. The tempo change itself does not take up any time.

If a line contains music (15 characters long, all characters either . or O), then those notes should be played and sustained for the correct duration (given by the tempo).

If a line does not fall into either of the above categories (like Music from... and CDEFG... in the above example), then it should be ignored completely. The program should act as if they weren't there, simply skip over them with no pause.

Output

Output could either be sound from the speakers, or a playable .MP3 or .WAV music file.

QUESTIONS

Should this be code golf? I assume so, although I want an added bonus for improved sound quality.