Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sound when placing stones. #96

Closed
qcgm1978 opened this issue Oct 14, 2023 · 4 comments
Closed

Add sound when placing stones. #96

qcgm1978 opened this issue Oct 14, 2023 · 4 comments

Comments

@qcgm1978
Copy link
Contributor

In the draw_stone method, play the sound after draw_last_move. This is more intuitive. For example, you can make these changes:

pachi = '../external/sound/0.mp3'
const pachi_audio = new Audio(pachi);
function draw_stone(h, xy, radius, draw_last_p, draw_loss_p, g) {
    ...
    if (draw_last_p && h.last && h.move_count > R.init_len) { 
        draw_last_move(h, xy, radius, g)
        g.canvas.id == 'goban_overlay2' &&
            pachi_audio.play()
    ...
kaorahi added a commit that referenced this issue Oct 14, 2023
@kaorahi
Copy link
Owner

kaorahi commented Oct 14, 2023

Would you try this?
https://github.com/kaorahi/lizgoban/tree/issue96_sound

(Usage)
Prepare sound files and put them into external/ directory. Then add "sound_file" into config.json like this.

{
    ...
    "sound_file" : {
        "stone": ["stone1.wav", "stone2.wav", "stone3.wav"],
        "capture": ["capture.wav"],
        "pass": ["pass.wav"]
    },
    ...
}

It may be a fun idea to adjust the sound based on the game situation (settled/unsettled, etc.), though I'm not planning to implement it soon.

@qcgm1978
Copy link
Contributor Author

Wonderful. I tried it and copied audio files to external folder. All works perfectly. But I want to know what's the meaning there're multi files as stone's value. Additionally, I believe that default sound files should be provided, even though users can customize their settings.

@kaorahi
Copy link
Owner

kaorahi commented Oct 16, 2023

If you specify two or more sound files, one of them will play randomly each time. I believe this approach is popular for creating a natural sound effect. For the default sound, do you know of any files with explicit licensing for copying and distribution?

@qcgm1978
Copy link
Contributor Author

Sabaki is licensed under the MIT license. I don't know whether it is appropriate.

kaorahi added a commit that referenced this issue Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants