Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Playing Audio Using Keystrokes: Is It Possible?

Annabelle5893

Gold Coder
I'm wondering, how would I make an app that plays audio files using the keys on the number pad? Specifically, I want to make an app that triggers "Rotary Pulse 1" by pressing 1 on the numeric keypad, all the way up to "Rotary Pulse 0" on the 0 key. A dial tone will be toggled on by pressing the spacebar, which will begin with a "receiver pickup" noise. The dial tone turns off when digits are dialed via the numeric keypad. If you press the spacebar either when the dial tone is on, or after dialing a number, a "Receiver Hang Up" noise will be triggered. With the rotary dial sounds, the dial turning to the fingerhole is triggered at key down, and the release of the dial returning to the resting position will be triggered by releasing of the number corresponding to the fingerhole (1, 2, 3, 4, 5, 6, 7, 8, 9, 0). This will be accompanied by the internal sound of the dial pulses as heard in a telephone. What is the code I would use to make this audio app using HTML?
 
I tried the "opacity" parameter, but my screenreader can't seem to detect that the buttons are there when I open the page in Firefox. Should I try it in Microsoft Edge? If it still doesn't work, what am I forgetting?
 
There seems to be no change, as there might be an error of an alleged "Missing ) after an argument". 1701568640319.png
However, I don't understand where there's a missing closed parenthesis at line 411, when it's actually there. What did I do wrong?
 
There seems to be no change, as there might be an error of an alleged "Missing ) after an argument". View attachment 2421
However, I don't understand where there's a missing closed parenthesis at line 411, when it's actually there. What did I do wrong?
Are you sure it's there? lol, Either one of 2 things
1) you really are missing a parenthesis,
OR
2) you have an extra parenthesis.

Can you click on that link on the error and see where in the code it points to?
 
Are you sure it's there? lol, Either one of 2 things
1) you really are missing a parenthesis,
OR
2) you have an extra parenthesis.

Can you click on that link on the error and see where in the code it points to?
It says the error is on line 411:6. When I check there, it seems like everything's as it should be, as there is in fact a ) as part of the character set "});".
 
Sure! I'm also posting the code surrounding it for contextual purposes.

Code:
        case 109:
button.addEventListener('click', function() {
            dialPound();
});
            break;
        default:
            hasDialedNumber = false;
            break;
    });
    }
Can you post that entire function there?...I have a funny feeling it may be related to the issue we were discussing before your hiatus 🙂 regarding misplaced/extra parenthesis/brackest
 
Can you post that entire function there?...I have a funny feeling it may be related to the issue we were discussing before your hiatus 🙂 regarding misplaced/extra parenthesis/brackest
My hiatus was caused by lack of Internet access, due to the fact that my apartment complex cut off their Internet access as it was becoming "financially unsustainable" and the connection was poor quality (they originally had Comcast, but they switched to Century Link when they changed property companies from Cornerstone Real Estate to Cambridge Real Estate, and then to Guardian Real Estate). The property manager, Charity, a real good friend of mine, recommended that I get my own, so I applied for Xfinity Internet Essentials Plus, which is covered by the Affordable Connectivity Program ($29.95 a month), and now, as my friend, Markus and I would say, "We're golden!".
 
Last edited:
My hiatus was caused by lack of Internet access, due to the fact that my apartment complex cut off their Internet access as it was becoming "financially unsustainable" and the connection was poor quality (they originally had Comcast, but they switched to Century Link when they changed property companies from Cornerstone Real Estate to Cambridge Real Estate, and then to Guardian Real Estate). The property manager, Charity, a real good friend of mine, recommended that I get my own, so I applied for Xfinity Internet Essentials Plus, which is covered by the Affordable Connectivity Program ($29.95 a month), and now, as my friend, Markus and I would say, "We're golden!".
That is unfortunate, but no need to disclose that 🙂 issues happen, we're all human and we've all gone through it lol. When I mentioned your hiatus, I wasn't referring to the actual hiatus itself, I was referring to the last conversation we had regarding your code having misplaced brackets. I brought it up to not only jog your memory as to where we left off while debugging your code, but to hint at the fact that this new error you got may be related to that 🙂. Go ahead and post the code that belongs to that particular function where the error is found and we'll if that is indeed the case
 
That is unfortunate, but no need to disclose that 🙂 issues happen, we're all human and we've all gone through it lol. When I mentioned your hiatus, I wasn't referring to the actual hiatus itself, I was referring to the last conversation we had regarding your code having misplaced brackets. I brought it up to not only jog your memory as to where we left off while debugging your code, but to hint at the fact that this new error you got may be related to that 🙂. Go ahead and post the code that belongs to that particular function where the error is found and we'll if that is indeed the case
Here's the code of the function that matches the "case" of "Case 109".

Code:
function dialPound(){
    if(allowDial == true) {
        numberDial();
        number=number+"#";
        var DTMFToneDialPound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');
        DTMFToneDialPound.play();
    }
}
 
Here's the code of the function that matches the "case" of "Case 109".

Code:
function dialPound(){
    if(allowDial == true) {
        numberDial();
        number=number+"#";
        var DTMFToneDialPound=new Audio('file:///M:/Documents/Virtual%20Phone/DTMF%20Tone%20Dials/DTMF Tone Dial Pound.ogg');
        DTMFToneDialPound.play();
    }
}
What about the function that holds that case statement?
 
What about the function that holds that case statement?
Are you talking about this?
Code:
document.onkeydown = function (event) {

    switch (event.keycode) {
        case 32:
button.addEventListener('click', function() {
            toggleLineStatus();
});
            break;
        case 49,97:
button.addEventListener('click', function() {
            dial1();
});
            break;
        case 50,98:
button.addEventListener('click', function() {
            dial2();
});
            break;
        case 51,99:
button.addEventListener('click', function() {
            dial3();
});
            break;
        case 52,100:
button.addEventListener('click', function() {
            dial4();
});
            break;
        case 53,101:
button.addEventListener('click', function() {
            dial5();
});
            break;
        case 54,102:
button.addEventListener('click', function() {
            dial6();
});
            break;
        case 55,103:
button.addEventListener('click', function() {
            dial7();
});
            break;
        case 56,104:
button.addEventListener('click', function() {
            dial8();
});
            break;
        case 57,105:
button.addEventListener('click', function() {
            dial9();
});
            break;
        case 106:
button.addEventListener('click', function() {
            dialStar();
});
            break;
        case 48,96:
button.addEventListener('click', function() {
            dial0();
});
            break;
        case 109:
button.addEventListener('click', function() {
            dialPound();
});
            break;
        default:
            hasDialedNumber = false;
            break;
    });
    }
 
Are you talking about this?
Code:
document.onkeydown = function (event) {

    switch (event.keycode) {
        case 32:
button.addEventListener('click', function() {
            toggleLineStatus();
});
            break;
        case 49,97:
button.addEventListener('click', function() {
            dial1();
});
            break;
        case 50,98:
button.addEventListener('click', function() {
            dial2();
});
            break;
        case 51,99:
button.addEventListener('click', function() {
            dial3();
});
            break;
        case 52,100:
button.addEventListener('click', function() {
            dial4();
});
            break;
        case 53,101:
button.addEventListener('click', function() {
            dial5();
});
            break;
        case 54,102:
button.addEventListener('click', function() {
            dial6();
});
            break;
        case 55,103:
button.addEventListener('click', function() {
            dial7();
});
            break;
        case 56,104:
button.addEventListener('click', function() {
            dial8();
});
            break;
        case 57,105:
button.addEventListener('click', function() {
            dial9();
});
            break;
        case 106:
button.addEventListener('click', function() {
            dialStar();
});
            break;
        case 48,96:
button.addEventListener('click', function() {
            dial0();
});
            break;
        case 109:
button.addEventListener('click', function() {
            dialPound();
});
            break;
        default:
            hasDialedNumber = false;
            break;
    });
    }
Look at the ending there, towards that default statement...
Are you positive it should end in "});" ?
 
So, if you look at the code carefully,
there are two main opening bracket one at the function level, and one at the switch statement. There should be one corresponding closing bracket at the end of the default statement, to close out the switch body, and one corresponding closing bracket after that, to close our the function body. There shouldn't be and parenthesis there.
 

Latest posts

Buy us a coffee!

Back
Top Bottom