lizgoban
lizgoban copied to clipboard
Add sound when placing stones.
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()
...
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.
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.
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?
Sabaki is licensed under the MIT license. I don't know whether it is appropriate.