New years challenge!

This is a discussion on New years challenge! within the Contests Board forums, part of the Community Boards category; Using only assembly and a single beep() statement, write a program that plays a familiar christmas tune. You cant use ...

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189

    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
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    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

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    I don't get it ... why only assembly? This site assemblyprogramming?

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    I don't even have a system speaker It's broken.

    Ohh and yes... why assembly?

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Hope I picked a song that is allowed. Easy note arrangement.

  6. #6
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    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

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by mike_g View Post
    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.

    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.
    Last edited by abachler; 12-24-2007 at 09:35 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  8. #8
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    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?

  9. #9
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    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...

    Anyway.

    I guess only "IA-32 assembly" will be accepted, right ?

  10. #10
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by mike_g View Post
    Or can we post code after compiler optimization?
    As long as the assembly is from code you wrote, this is acceptable.

    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  11. #11
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    What if it connects to MSN and we type in the song ourselves?

  12. #12
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    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....

    ::edit::

    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 .
    Last edited by GanglyLamb; 12-25-2007 at 08:47 AM.

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by zacs7 View Post
    What if it connects to MSN and we type in the song ourselves?
    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.

    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.
    Last edited by abachler; 12-26-2007 at 09:03 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #14
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    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?

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  15. #15
    Banned
    Join Date
    Nov 2007
    Posts
    678
    why it has to be in assembly?

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Delete Files Older than 2 years
    By Dragoon_42 in forum C++ Programming
    Replies: 10
    Last Post: 05-17-2007, 05:13 PM
  2. Converting seconds to years, months etc...
    By ^xor in forum C Programming
    Replies: 7
    Last Post: 08-07-2005, 12:30 AM
  3. Where will programming be in 30 years ?
    By mrpickle in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 01-08-2004, 05:42 AM
  4. Requesting a challenge
    By RealityFusion in forum C++ Programming
    Replies: 8
    Last Post: 08-18-2003, 09:24 PM
  5. Video Games Industry. 5 years left.
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 12-10-2002, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21