Importing music files into Second Life

[Note: to avoid stops and starts if you have a slow internet connection, pause the video for 30 seconds or so at the beginning to allow a minute or two of video to buffer before playing.]

Download track

Advertisements

8 Responses to Importing music files into Second Life

  1. antonleman says:

    Nice tutorial, and funny. Even my family liked it 🙂
    However, I couldn’t get the Juke player code at said coordinates – your CDs on shelves refused cooperation.
    So I created another piece of code with similar functionality, but with slight improvement. Namely, I noticed that there were audible breaks (or rather inaudible, since there was no music) at the points where audio chunks where supposed to join. I came up with an idea to split the track to 9 second long intervals, but each chunk started at multiplicity of 8. Hence there were overlapping 1 second chunks. So, in the script, I played 9-sec chunks with 8-sec timing.
    Now, provided that bandwidth is good and SL doesn’t play tricks, the audio is a bit nicer to listen to.

  2. Anton, I’ve now had a look at it — this is excellent! good work! Would you like to share your script with the rest of us?

  3. antonleman says:

    Sure I can. I thought I had sent the item with full permissions, maybe I messed up something 🙂

    Put audio chunks into object, then add the script:
    *******************

    // ==========================================================================
    // AudioPlayer 1.0
    // Author Anton Leman
    // Script plays attached sounds with 8.0 sec timer
    //============================================
    // Declare globals
    string version = “1.0”;
    integer numSounds = 0; //numer of attached sounds
    list gSounds = []; //list to store sound names
    integer songNo = 0; //No of current sound in the list
    integer play = 0; //player switch
    default
    {
    state_entry()
    { //loading the list with sound names
    integer i = 0;
    numSounds = llGetInventoryNumber(INVENTORY_SOUND);
    for (i=0; i1)
    llPreloadSound(llList2String(gSounds, songNo));
    llPreloadSound(llList2String(gSounds, songNo+1));
    //play the 1st one
    llPlaySound(llList2String(gSounds, songNo), 1.0);
    //and start the timer with 8.0 interval
    llSetTimerEvent(8.0);
    //song number for next iteration/call in timer method
    songNo++;
    }
    else
    {
    //if NO PLAY, then stop, reinitiate song number, disable timer
    llStopSound();
    songNo = 0;
    llSetTimerEvent(0.0);
    }

    }

    timer()
    {
    //check the number of chuncks against currently played chunk
    if (numSounds>songNo)
    {
    //we still have more to play, go on
    llPlaySound(llList2String(gSounds, songNo), 1.0);
    //preload only if there will be more
    if (numSounds>songNo+1) {
    llPreloadSound(llList2String(gSounds, songNo+1));
    }
    //song number for next iteration/call in timer method
    songNo++;
    }
    else {
    //if the last has just finished, reinitiate and stop timer
    play = 0;
    songNo = 0;
    llSetTimerEvent(0.0);
    }
    }
    }

    • Anton thank you for the script! I tried though to use it in opensimulator in my world and found error. The compiller stops at “numSounds = llGetInventoryNumber(INVENTORY_SOUND);” could you please help me with this? I suppose something is wrong with me but what? Thanks in advance!

  4. antonleman says:

    Do you have any sound files in your object when launching this script? If compiler stops at getting sounds out of inventory, it can mean there are no sounds.
    Another note, the script is supposed to play several files, hence there is assumption of at least 2 files. If there is less, most of the code is unnecessary.

    • i put two files (wav files) in the object. Tried to compile but nothing. I suppose tha the error is due to incompatible web characters (from the site to the script). So can you send me an email of the script directly from you?

  5. antonleman says:

    Yes, give me your email.
    Cheers

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s