Does anyone have a capx which plays sounds at 0db once?

0 favourites
  • 4 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hey guys,

    I'd like to add a feature to my piano app which plays every key (note) once and 0db (silent) and then, once that is complete, turns up the volume again and make the app ready for use.

    Does anyone happen to have a capx which has these features already implemented?

    I've read a tutorial on how to play sounds with functions but it doesn't look like a solution that is ideal for my situation.

    Even if someone could post just how to play one sound and change the volume would be enough for me to learn from.

    Thanks,

    V

  • Hey vancouver <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    To play a sound at an inaudible volume (essentially silent), you'll probably want to use something like -60 dB or lower. Decibels (dB) are logarithmic units of volume, so "0 dB" is actually full volume, (100% original sound volume).

    Decibels are kind of a weird scale. And to make things weirder, computers use the dB scale differently than the way it's used to describe the loudness of sounds in the real world.

    Computer dB

    When dealing with computer audio, most programs use the convention that a sound's original (100%) volume is "0 dB", no matter what the sound is. Could be crinkling paper, could be a jackhammer, but on a computer 0 dB means play this sound file at 100% of whatever volume it was recorded at.

    Decibel scale

    When you *add* to a sound's dB level, you *scale* its power level up.

    When you *subtract* from a sound's dB level, you *scale* its power level down.

    (I say "power" rather than "loudness" because the human perception of audio signal power has its own non-linear issues.)

    Adding +10 dB to a 0 dB sound gives you the original sound power times 10.

    Adding +20 dB to a 0 dB sound gives you the original sound times 10, and then times another 10, for a total of times 100.

    Adding +30 dB to a sound yields 10 x 10 x 10, or 1000 times more power.

    And -30 db scales it down by 1000, making it 1/1000th the original power.

    So, playing a sound at -60 dB is playing it at 1/1,000,000th its normal volume, which is going to be silent enough. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    For more confusion, here's the wiki page for Decibels ... http://en.wikipedia.org/wiki/Decibel

    Preload sounds

    All that said, if you're looking to play all the sounds once to force them to preload, so that there's no delay the first time a user tries to play a note, then there's good news.

    As of one of the recent updates to Construct 2, a "Preload sounds" option was added to the project properties in the "Configuration Settings" section. This will automatically preload all sounds (not including sounds in the "music" folder).

    Playing all sounds once

    If you need to play every sound once, you could create an event "Start of layout", with an action "Play sound" at -60 db for each sound.

    Or, if your sound files are named with a fixed name followed by a number (e.g. "note00", "note01" , "note02", etc) then you could create a loop using the action "play sound by name", using the name [ "note" & zeropad( loopindex , 2 ) ].

    The zeropad() function will convert a number to a string with a fixed number of digits, such that leading zeros are used when the converted number isn't large enough to fill the fixed digit amount. e.g. zeropad( 77 , 5 ) = "00077"

    Hope that helps. Sorry for the long explanation of the dB scale. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for shedding light on this issue.

    I will implement your suggestion(s) which will provide a better user experience.

    Safari, Chrome and FF seem to work fine but IE still waits for that first touch per piano key.

    I'm sure that your reply will be useful for many of us,

    Thank you so much for providing it,

    V

  • No problem. Glad I could help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)