Recent

Author Topic: [SOLVED] Sound Callback  (Read 2700 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[SOLVED] Sound Callback
« on: March 16, 2021, 09:41:32 am »
I was given the following code (DELPHI), see attachment, but can't get it to compile / work.

It's supposed to implement a callback for sound change notifications. It works as such but I cant compile

PostMessage(Handle, WM_VOLNOTIFY, WPARAM(pNotify.bMuted <> False), LPARAM(Round(100 * pNotify.fMasterVolume)));

If I change to

PostMessage(Handle, WM_VOLNOTIFY, 0, 0);

It works, but, of course, I get no information what has changed ...

Any help appreciated.

Thanks in advance.
« Last Edit: March 16, 2021, 11:02:42 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Sound Callback
« Reply #1 on: March 16, 2021, 11:01:45 am »
Just needed to dereference the pointer.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Sound Callback
« Reply #2 on: March 16, 2021, 12:57:53 pm »
Just needed to dereference the pointer.

Hello PCurtis.

Congrats, you did it ! ;D

Quote
If I change to

PostMessage(Handle, WM_VOLNOTIFY, 0, 0);

It works, but, of course, I get no information what has changed ...

You have more luck than me, even changing this in your demo (that compiles out-of-the-box) here nothing appends if I change the Windows-mixer-volume, the callback does not start.

[EDIT] Ooops, no, sorry, it works perfectly on Windows 10 (but not via Linux wine emulator).

Many thanks to share this code (and thanks to Him if he helped you).


Fre;D

« Last Edit: March 16, 2021, 01:13:29 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: [SOLVED] Sound Callback
« Reply #3 on: March 16, 2021, 01:12:55 pm »
Try this (attachment)

Win 10, Laz 2.0.12
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: [SOLVED] Sound Callback
« Reply #4 on: March 16, 2021, 01:15:00 pm »
Hello Curtis.

Re-oops we sent the post together, please take a look at my [EDIT].

I will try your new code now.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: [SOLVED] Sound Callback
« Reply #5 on: March 16, 2021, 01:37:09 pm »
Hello PCurtis.

This one is a very Big Wow.

 :o

I was never able to do this since Windows 3.1 on Delphi.
And of course did not try to do it with fpc.

It would be marvelous if you share this code on a site like GitHub.

I am busy to do the same for Linux via libasound.so (but not yet ready, the callback fire only ones here).

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: [SOLVED] Sound Callback
« Reply #6 on: March 16, 2021, 01:57:07 pm »
Do what you want with the code.

It comes with a "Couldn'tGiveAShit" license.

The only clause is:

1. If you sell it and make loads of money, I want a cut.  :)
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: [SOLVED] Sound Callback
« Reply #7 on: March 16, 2021, 02:13:39 pm »
Do what you want with the code.

It comes with a "Couldn'tGiveAShit" license.

The only clause is:

1. If you sell it and make loads of money, I want a cut.  :)

Personally, I dont use Windows for centuries now.

And I dont want to be rich.

But also it would be a crime to let this code in the dark.

So, ok, let's become rich (OK for 100% to you and the rest for me?).

Thanks PCurtis.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: [SOLVED] Sound Callback
« Reply #8 on: March 17, 2021, 06:39:46 pm »
Hello.

Here code to set/get Windows Master Volume and assign the callback procedure of system mixer.
With a console demo.
This thanks to PCurtis.
https://github.com/fredvs/win_mixer

There is the same for Linux here:
https://github.com/fredvs/alsa_mixer

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018