Forum Discussion

tristaanogre's avatar
tristaanogre
Esteemed Contributor
8 years ago
Solved

Happy Holidays

Back in 2008, HKosova posted a blog article where she described how you can do all sorts of fancy stuff with TestComplete, including playing a holiday song.  You can read it for yourself.

 

http://blog.smartbear.com/software-quality/how-to-make-testcomplete-play-a-holiday-song/

 

Well, last night, I got inspired and said to myself, "Why stop at one song? Why not code to play ANY song?"

So... starting with Helen's fantastic code, I created a Script Extension with no real world useful purpose other than to play music.  You can download the MusicBox from my repository on bitbucket and install it in your TestComplete environment.

To play Helen's original holiday tune, open a new JavaScript project in TestComplete. In the Unit1 script unit created, copy and paste this code in:

function HolidayTune() {
    MusicBox.PlaySong(MusicBox.JingleBells);
}

Run the code... and enjoy!

 

If you want to "write" a new song, all you need to do is something like this:

 

function MySong() {
var CMajorScale = [new MusicBox.Lyrics('This is a C Major Scale'),
                   new MusicBox.Notes('C4', 2000), 
                   new MusicBox.Notes('D4', 2000), 
                   new MusicBox.Notes('E4', 2000), 
                   new MusicBox.Notes('F4', 2000), 
                   new MusicBox.Notes('G4', 2000), 
                   new MusicBox.Notes('A5', 2000), 
                   new MusicBox.Notes('B5', 2000), 
                   new MusicBox.Notes('C5', 2000)];

    MusicBox.PlaySong(CMajorScale);
}

Have fun, and happy holidays!

 

[EDIT] P.S.  The extension is chromatic... you can do ASHARP3 or EFLAT5 or other such designations to get the half steps in the chromatic scale.

  • Happy Holidays, Guys :) 

     

    tristaanogre, great to see that HKosova's project is till so popular!

     

    We've prepared another song - this is a traditional Russian song that we sing since our childhood. It tells about a long way a Christmas tree should travel before getting into our houses and bringing happiness to our families.

    Enjoy the song :)

     

     

    var EIGHTH = 2000, HALF = EIGHTH /2, QUARTER = HALF /2, EIGHTH = QUARTER /2, SIXTEENTH = EIGHTH /2;
    
    var LittleTree = [new MusicBox.Lyrics("V lesu rodilas elochka"),				   
        new MusicBox.Notes('C5', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('G5', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('F5', QUARTER),  
        new MusicBox.Notes('C5', QUARTER),  
        new MusicBox.Notes('C5', QUARTER),  
        new MusicBox.Lyrics("V lesu ona rosla"),
        new MusicBox.Notes('C5', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('BFLAT6', QUARTER),
        new MusicBox.Notes('G5', QUARTER),
        new MusicBox.Notes('C6', HALF),  
        new MusicBox.Notes('REST', QUARTER),  
        new MusicBox.Lyrics("I mnogo mnogo radosti"),
        new MusicBox.Notes('C6', QUARTER),
        new MusicBox.Notes('D5', QUARTER),
        new MusicBox.Notes('D5', QUARTER),
        new MusicBox.Notes('BFLAT6', QUARTER),
        new MusicBox.Notes('BFLAT6', QUARTER),
        new MusicBox.Notes('A6', QUARTER),  
        new MusicBox.Notes('G5', QUARTER),  
        new MusicBox.Notes('F5', QUARTER),  
        new MusicBox.Lyrics("Detishkam prinesla"),
        new MusicBox.Notes('C5', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('G5', QUARTER),
        new MusicBox.Notes('A6', QUARTER),
        new MusicBox.Notes('F5', HALF)];
        
    function HolidayTune() {
       
        MusicBox.PlaySong(LittleTree);
    }

     

16 Replies

  • Ha ha ha ha ha ha ha! :D

     

    I've seen it all now!

     

    It should be called "DriveYourColleaguesInsane" rather than "MusicBox" though ......

  • baxatob's avatar
    baxatob
    Community Hero

    Unbelievable!
    This is the first time when I sorry, that our servers have no sound cards...

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    baxatob as far as I understand it, you don't need a sound card. It makes use of aqUtils.Beep which uses the PC speaker.
    • baxatob's avatar
      baxatob
      Community Hero

      No any beeps & speakers in our virtual environment. Cold & silence here...

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        baxatob wrote:

        No any beeps & speakers in our virtual environment. Cold & silence here...


        Suddenly... I'm very sad... feeling kinda like the Cratchets... Tiny Tim will sing no more...