New years challenge!
Using only assembly and a single beep() statement, write a program that plays a familiar christmas tune.
You cant use a table of values. You have to calculate the next note and duration through some algorithm.
You can obviously use the Beep() in a loop to play the notes.
Happy Holidays and good luck :)
This looks hard. By the way, in which header file is Beep defined ? I don't find it in the standard header files, only find it in <windows.h>... huh.
Help me :)
I don't get it ... why only assembly? This site assemblyprogramming?
I don't even have a system speaker :( It's broken.
Ohh and yes... why assembly?
Hope I picked a song that is allowed. Easy note arrangement. :D :D :D
An ASM only challenge on a C board is just stupid. Why don't we do it in Malbolge? Makes no difference to me o_0
inline assembly is a part of most modern C/C++ compilers. Wheres the challenge in an easy contest? This is a contest for intermediate/advanced programmers, not noobs. And if it makes no difference to you, then you are OK with the contest the way it is.
Originally Posted by mike_g
Beep() is in <windows.h> Sorry I dont knowlinux well enough to suggest a similar function there.
Song selection will play a role in the contest, since different techniques may be more suitable to some songs than others.
Well I guess I 2 noob. I might have had a go in C, but have fun all the same ;)
Or can we post code after compiler optimization?
Anyway, i believe the hard part of this challenge isn't about the fact it has to be written in assembly, but that you need to find some sort of "algorithm" to calculate the next note and duration. This is what i believe the tricky part, i don't really have any idea and/or enough knowledge to think of something who could achieve this for something as complex as a song. But the term "algorithm" is rather large and incrementing an index and looking in a table is an algorithm...
I guess only "IA-32 assembly" will be accepted, right ?
As long as the assembly is from code you wrote, this is acceptable.
Originally Posted by mike_g
I know looking into a table is an algorithm, but thats just way too easy. Finding a function that produces values you use is a bit more of a challenge, and is of course the interesting part of the contest.
Ill give you a hint on a way to solve it on the 26th if noone has made an entry or suggested another means.
What if it connects to MSN and we type in the song ourselves? :)
This is how I would do this: ( probably not the best way but still ).
See the song as a function with a period T (which is the duration of the song). Now use fourier ... ( I would actually define the function in maple, piecewise, then let maple do its magic and go for n=1 to n=1000). Then take this function, write it in assembler using some sort of lookup table for the sin and cosine. Afterwards, for the minimal amount of time a note is being played for instance 0.1 second, step trough the function (the mathematical expression), round to the nearest reall note which is also defined somewhere... and output using beep.
Its not a lookup method , unless you say that the function actually is a lookup table or something... but then again, every piece algorithm can be defined in that way....
Thinking about this, it would actually take quite some time to determine the fourier approximation....
On the other hand the objective; using an algorithm can easily be done, by just substracting, adding, division etc of the start note its frequency..., of course this would result in something quite big (depending how many notes te be played but still). Then the question is again what is an algorithm, it would be more specific if you would say , write a method, that takes as input the note to start with for this or this song, depending on this note, shift the complete tone of the song one up or one down or whatever... then it would require something more complicated (taking into account you can not use lookup tables).
Anyhow, im not competing in this in any way just wanted to spill my thoughts on it :).
If you plan to sit at your computer 24 hours a day for several days in the hopes of doing that at exactly the moment I decide to run your entry and in the hopes that I run it on a computer with an internet connection instead of a hardened system, well, be my guest.
Originally Posted by zacs7
Now I promised a clue as to one method of doing this, so here goes.
X = (X * K) MOD P
Ill provide another hint tomorrow. Remember, the method im hinting at is only one of many that will work.
Without supreme cleverness, I can't see how to do this.
Option I see is to basically encode the song into a discrete fourier transform, which is not far from a mere table of values.
This doesn't make any sense
X = (X * K) MOD P
X = 5, K = 2, P = 3
Like what? Is that not a mathematical equation in the traditional sense?
Rather a sequence X sub N = (X sub N-1 * K) MOD P?
why it has to be in assembly?