Lazarus

Programming => Graphics and Multimedia => Audio and Video => Topic started by: pcurtis on March 16, 2021, 09:41:32 am

Title: [SOLVED] Sound Callback
Post by: pcurtis 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.
Title: Re: Sound Callback
Post by: pcurtis on March 16, 2021, 11:01:45 am
Just needed to dereference the pointer.
Title: Re: Sound Callback
Post by: Fred vS 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

Title: Re: [SOLVED] Sound Callback
Post by: pcurtis on March 16, 2021, 01:12:55 pm
Try this (attachment)

Win 10, Laz 2.0.12
Title: Re: [SOLVED] Sound Callback
Post by: Fred vS 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
Title: Re: [SOLVED] Sound Callback
Post by: Fred vS 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
Title: Re: [SOLVED] Sound Callback
Post by: pcurtis 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.  :)
Title: Re: [SOLVED] Sound Callback
Post by: Fred vS 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
Title: Re: [SOLVED] Sound Callback
Post by: Fred vS 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
TinyPortal © 2005-2018