Skip to content

Sound APIs on Windows#4522

Closed
mattn wants to merge 16 commits intovim:masterfrom
mattn:sound-windows
Closed

Sound APIs on Windows#4522
mattn wants to merge 16 commits intovim:masterfrom
mattn:sound-windows

Conversation

@mattn
Copy link
Member

@mattn mattn commented Jun 10, 2019

This is work in progress. Current status:

sound_playfile: done
sound_stop: done
sound_clear: done

@k-takata
Copy link
Member

@mattn I will create a patch for Make_mvc.mak later.

@k-takata
Copy link
Member

@mattn Could you import this patch?
https://gist.github.com/k-takata/4a8c42377c3256f1e29d26183b4b2a39

@mattn
Copy link
Member Author

mattn commented Jun 11, 2019

@k-takata Will do tonight. Thank you.

@mattn
Copy link
Member Author

mattn commented Jun 11, 2019

I applied review fixes. I noticed that implementing sound_playevent() is bits hard. The reasons are:

  • mciSendString does not allow alias name like "SystemAlert".
  • PlaySound() that can allow filename or "SystemAlert" does not work with callback.
  • PlaySound() can not stop sound indivisually.
  • "SystemAlert" is embeded in "mcires.dll".
  • Windows does not have XDG sound list.

@brammool
Copy link
Contributor

brammool commented Jun 11, 2019 via email

@mattn
Copy link
Member Author

mattn commented Jun 11, 2019

Does MS-Windows install some of these sounds, so that they can be played
as sound files? Then we could map some event names to them. I rather
not include sound files in the distribution, except some very basic ones
like "bell". I assume plugins can include files in a way they play on
any system with the +sound feature. .wav files should work, libcanberra
also handles .ogg and other formats.

Older version of Windows install them. But Windows 10 does not install them. All of sound resource are bundled in mcires.dll as resource file. PlaySound() API can play the resource sound. But PlaySound() is not used with callback as I mentioned in above.

@brammool
Copy link
Contributor

brammool commented Jun 11, 2019 via email

@k-takata
Copy link
Member

Is that doable?

I think it is possible, but the problem is that PlaySound() cannot stop the sounds individually.
It can stop all the sounds only. Another way is playing only one sound at once. If there is a new call of PlaySound(), stop the old sound.

@codecov-io
Copy link

codecov-io commented Jun 12, 2019

Codecov Report

Merging #4522 into master will increase coverage by 0.17%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4522      +/-   ##
==========================================
+ Coverage   80.65%   80.82%   +0.17%     
==========================================
  Files         111      111              
  Lines      143838   144338     +500     
==========================================
+ Hits       116011   116662     +651     
+ Misses      27827    27676     -151
Impacted Files Coverage Δ
src/sound.c 64.38% <ø> (ø) ⬆️
src/if_xcmdsrv.c 83.66% <0%> (-0.9%) ⬇️
src/gui.c 58.05% <0%> (-0.52%) ⬇️
src/screen.c 81.95% <0%> (-0.41%) ⬇️
src/dict.c 85.58% <0%> (-0.4%) ⬇️
src/netbeans.c 27.25% <0%> (-0.3%) ⬇️
src/gui_gtk_x11.c 49.16% <0%> (-0.25%) ⬇️
src/ex_cmds.c 82.18% <0%> (-0.25%) ⬇️
src/os_unix.c 60.63% <0%> (-0.05%) ⬇️
src/evalfunc.c 89.27% <0%> (-0.05%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12ee7ff...825abec. Read the comment docs.

@mattn
Copy link
Member Author

mattn commented Jun 12, 2019

Implemented sound_playevent() using PlaySound(). sound_playevent() return ID, but this can not be used for sound_stop().

@mattn mattn changed the title [WIP] Sound APIs on Windows Sound APIs on Windows Jun 12, 2019
@k-takata
Copy link
Member

@mattn Could you check this additional patch?
https://gist.github.com/k-takata/5fb38f305408a4bfa35221a5aec0f8ab

* Update document about sound_playevent() on Windows.
* Some lines exceeded 80 columns.
* Types of some variables were wrong.
@k-takata
Copy link
Member

@mattn AppVeyor is failing. We need to fix the test.
https://ci.appveyor.com/project/chrisbra/vim/builds/25258938/job/2h4no54pbcv7fert#L3620

@k-takata
Copy link
Member

We've done. I think this is ready to be merged.

@brammool brammool closed this in 9b28352 Jun 17, 2019
manuelschiller pushed a commit to manuelschiller/vim that referenced this pull request Nov 10, 2019
Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim#4522)
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 15, 2025
Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 18, 2025
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

vim/vim@37df9a4

---

Restore "highest_patch()" solely for "v:versionlong".
Copy/paste Test_vvar_scriptversion2() from patch 9.1.1540.
It works without ":scriptversion 2".
In general, if Vim's test works with ":scriptversion 1", just port it
for additional coverage.

Co-authored-by: Bram Moolenaar <Bram@vim.org>

vim-patch:8.1.1565: MS-Windows: no sound support

Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 19, 2025
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

vim/vim@37df9a4

---

Restore "highest_patch()" solely for "v:versionlong".
Copy/paste Test_vvar_scriptversion2() from patch 9.1.1540.
It works without ":scriptversion 2".
In general, if Vim's test works with ":scriptversion 1", just port it
for additional coverage.

Co-authored-by: Bram Moolenaar <Bram@vim.org>

vim-patch:8.1.1565: MS-Windows: no sound support

Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 20, 2025
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

vim/vim@37df9a4

Restore "highest_patch()" solely for "v:versionlong".
Copy/paste Test_vvar_scriptversion2() from patch 9.1.1540.
It works without ":scriptversion 2".
In general, if Vim's test works with ":scriptversion 1", just port it
for additional coverage.

---

vim-patch:8.1.1565: MS-Windows: no sound support

Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 20, 2025
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

vim/vim@37df9a4

Restore "highest_patch()" solely for "v:versionlong".
Copy/paste Test_vvar_scriptversion2() from patch 9.1.1540.
It works without ":scriptversion 2".
In general, if Vim's test works with ":scriptversion 1", just port it
for additional coverage.

---

vim-patch:8.1.1565: MS-Windows: no sound support

Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
dundargoc pushed a commit to dundargoc/neovim that referenced this pull request Sep 27, 2025
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

vim/vim@37df9a4

Restore "highest_patch()" solely for "v:versionlong".
Copy/paste Test_vvar_scriptversion2() from patch 9.1.1540.
It works without ":scriptversion 2".
In general, if Vim's test works with ":scriptversion 1", just port it
for additional coverage.

---

vim-patch:8.1.1565: MS-Windows: no sound support

Problem:    MS-Windows: no sound support.
Solution:   Add sound support for MS-Windows. (Yasuhiro Matsumoto, Ken Takata,
            closes vim/vim#4522)

vim/vim@9b28352

----

"sound" feature is N/A now but this updates "v:versionlong" docs.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants