Importing sound

I was looking/reading through some forums and saw that some had a line of code of importing audio.
How do I do this on my laptop? Is there a command like @import sound.mp3 that I can use to import an audio file from a folder to my game?


Hello.

Are you using Squiffy CLI (from the command line), or are you using the Squiffy editor?


Squiffy CLI

http://textadventures.co.uk/forum/squiffy/topic/wuznjcixz06r6o5jfngjwg/creating-a-game-with-audio-using-cli-only-this-includes-everything-from-install


Squiffy editor

https://textadventures.co.uk/forum/squiffy/topic/_4qhxoi370ijxy1zvpcwxg/adding-sound

NOTE

You have to manually drop the audio file into the final game folder before uploading your game.

Also, if you're testing your game from the editor, you probably won't hear your audio. This is because of the way the Squiffy editor runs a game. It creates a temp directory and runs the game from there. So, any image or audio files in your folder cannot be targeted locally from the editor because the path is all messed up. What does all this mean? Just build your game to see if the audio works. Don't test from the editor.


http://textadventures.co.uk/forum/squiffy/topic/ropioza3qkgyojd7mvo0ew/squiffy-how-can-i-change-the-audio-when-i-click-on-an-other-section-passage

This thread was helpful for me. I would imagine you have to upload your local files onto a filesharing website first.


I’m using the squiffy desktop editor, and have the music imported into the game files, however, I have tried to understand how import and auto play works since I tried the different variations and I still haven’t heard any sound from the game.


I use the desktop editor and got all sorts of sounds and music into my game. Here's how I did it (but it's been a while, so I'm a little hazy).

To start music at the title screen (but you need to move into another page to make it trigger)...

    if (get("currentMusic")==0){
        ogg = new Audio();
        ogg.src = "music_opener.mp3";
        ogg.loop=true;
        ogg.load();
        ogg.play();
        set ("ogg",ogg);
        set("currentMusic",1);
    }

Then, different music depending if you are in a room or passage...

    if (get("inHall") && (get("currentMusic")!=2)){
        ogg.pause();
        ogg.currentTime = 0;
    
        ogg = new Audio();
        ogg.src = "music_hall.mp3";
        ogg.loop=true;
        ogg.load();
        ogg.play();
        set ("ogg",ogg);
        set("currentMusic",2);
    }  
    if (get("inRoom") && (get("currentMusic")!=3)){
        ogg.pause();
        ogg.currentTime = 0;
    
        ogg = new Audio();
        ogg.src = "music_room.mp3";
        ogg.loop=true;
        ogg.load();
        ogg.play();
        set ("ogg",ogg);
        set("currentMusic",3);
    }  

Sound is a little more different but pretty easy - you can have sound appear over music without any trouble.

<audio src="ingest-drink.wav" autoplay />

Someone will have to remind me if there is more to this than I've shown. I don't fro the life of me remember what I went through to get this to work.

The finished product (my contemporary dungeon crawl beneath London) is below. You can see how sound and music mesh.

https://textadventures.co.uk/games/view/dmo-xkger0arz5csjfra8g/storeyminus


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums