Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:45:44+00:00 2026-06-16T00:45:44+00:00

Here is a link to my code: http://jsbin.com/ebadic/9/edit It is from a demo I

  • 0

Here is a link to my code: http://jsbin.com/ebadic/9/edit

It is from a demo I found here (this links explains how it works, the part i’m using is at the bottom):

http://www.html5rocks.com/en/tutorials/casestudies/jamwithchrome-interaction/

It creates 6 guitar strings. What I would like to do is have a sound play when one of the 6 strings is moused over – A different sound for each string, or a single sound that is pitched up/down for each string (perhaps using the playbackRate attribute)

My code already plays a sound when I mouseover a single string, but the problem is that it plays the same sound for each one. How do I make it play a DIFFERENT SOUND for each string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:45:45+00:00Added an answer on June 16, 2026 at 12:45 am

    You call strum() here:

    Stage.prototype.checkPoint = function(x, y, zone) {
        if(zone.inside(x, y)) {
            zone.string.strum();
        }
    };
    

    Why not add an <audio> identifier here?
    I suppose the sound you want to play depends on the x and y coordinates?

    Stage.prototype.checkPoint = function(x, y, zone) {
        if(zone.inside(x, y)) {
            zone.string.strum(getAudioID(x, y));
        }
    };
    

    How you fill in the getAudioID(x, y) is up to you (I am no musician, so I really do not know 🙂 )

    Of course you’d need to change the strum() method as well to something like this:

    GuitarString.prototype.strum = function(audioID) {
        this._strumForce = 5;
        document.getElementById(audioID).play();
    };
    

    (Up to here fits nicely into your current design.)


    A better approach is to add the audioID to your GuitarString class when you instantiate the guitar string objects. So each guitar string (object) uses its own audio track.

    Even though this would require some bigger modifications to your code, I would advice to do it this way as it results in much clear and understandable code!


    Also checkout Sound effects in JavaScript / HTML5 it shows how you can play audio tracks without using the <audio>-tag. This is particular useful when you have many audio fragments!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the link where I'm trying this: http://jsbin.com/ajirim/2/edit#source the js code: $(function(){ $('button').click(dao); });
Here's the link to my code: http://jsbin.com/edago3/edit I would love to find out what
EDIT: Here's a link to show you my sample code: http://www.singingeels.com/jqtest/ I have a
Here is the link to the sample code http://developer.apple.com/library/ios/#samplecode/MVCNetworking/Introduction/Intro.html Below is the code snippet
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here I have pasted link for code: http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/ In this code I have just
I'm learning by reading this tutorial: Link Here's the code: <?php require_once 'Zend/Loader.php'; class
In this example http://jsbin.com/inoka4 no width is defined for parent element if i want
I tried to checkout the GData for Obejctive-C client (found the link from here:
Here is link where i got a code for web-page content fetching. But i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.