Old 5th October 2003, 18:49   #1
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
When does a song start?

Hi,

I'm a Winamp 2 DSP plugin and I would like to be noticed when Winamp starts to play a file. I have subclassed the main Winamp window and tried some things to find out when playing starts:

1.Detecting when the filename of the currently played file changes - but then I overlook that the same file could be playing again.

2.Detecting when the Winamp title changes - but it changes three or four times every time playing starts so I can't really use that either - or don't know how I could use it without making mistakes.

Does anybody have other suggestions?
jocmir is offline   Reply With Quote
Old 6th October 2003, 13:09   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
you need to detect the start playing message in the main window, should be 100 as the wparam value (taken from here) this should work (not on my machine so can't check the exact code at the moment)

-daz
DrO is offline   Reply With Quote
Old 6th October 2003, 15:34   #3
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
Are you talking about the WM_USER message with id=100?
I thought this message can be sent to Winamp to make it start playing. I'm not trying to start playback, I'm trying to be noticed when playback started. Maybe I'm wrong but it does not seem to work. Thank you anyhow.
jocmir is offline   Reply With Quote
Old 6th October 2003, 16:52   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
sorry about that, meant wm_user not wparam

what you need to do is check for that message to be received and that indicates that playback is starting so you can then do whatever you need to do.

i'll check it out later on but above should be working

-daz
DrO is offline   Reply With Quote
Old 7th October 2003, 16:37   #5
DrO
 
Join Date: Sep 2003
Posts: 27,873
try this example

it will show a messagebox when play starts (detected in two ways - see below) and when the user clicks on stop (just to show).

it works by checking the ids of the timer messages in the wparam of wm_timer since when playing starts, a unique timer message is received (id == 42). however if you are using an autoplay plugin then depending on the load order your plugin may or may not have been loaded by that time so it will not detect playback starting. the fix is to look for an id of 38 with the wm_timer which is only used when playing and then set an internal flag to indicate it has been detected.

also had a look at the dsp thing and if you're creating a dsp i don't think you need to know when playback starts since winamp will call the selected dsp when playback starts anyway. well that's how i've taken it from playing with the dsp example project here.
Attached Files
File Type: zip test.zip (40.0 KB, 220 views)
DrO is offline   Reply With Quote
Old 7th October 2003, 22:29   #6
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
daz, I appreciate your work very much. Checking the wm_timer messages did not come to my mind. I did not want to see them in spy++ because they flooded the screen immediately so I overlooked that they are changing while a song is played.

Thank you for the hint and for the example project!

Having said that, I noticed a problem with your method of detecting when a file is played:
wm_timer with id 42 is also sent twice when you minimize the winamp window to the smaller interface (the very thin one with everything in one line)

I am currently trying to put the parts together, maybe I can get an error-proof method by combining them.

Even though Winamp controls the DSP plugin I need to know when a file is played because I want to load a value from disk that determines the amplification level of the current song.

-jochen
jocmir is offline   Reply With Quote
Old 7th October 2003, 23:42   #7
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
I think I got it! Now I'm using this code in the CALLBACK function:
code:
// catches when a play starts but will not if playing has already
// started when the plugin is loaded
if(umsg == WM_TIMER){
if(wp == 42 && title_changed){
started = 1;
title_changed = 0;
MessageBox(hwnd,"Starting","",0);
}
// otherwise check for timer id 38 which indicates it's playing!
else if(!started && wp == 38){
started = 1;
title_changed = 0;
MessageBox(hwnd,"Started","",0);
}
}

// check if the user stops or song ends
else if((umsg == WM_COMMAND && LOWORD(wp) == WINAMP_BUTTON4)
|| umsg == WM_USER+2){
MessageBox(hwnd,"Stopped","",0);
started = 0;
title_changed = 0;
}

// check if title has _really_ changed
if((umsg == WM_SETTEXT) && strcmp((char*)lp,last_title))
{
title_changed = 1;
strcpy(last_title,(char*)lp);
}


// Call Winamp Window Proc
return CallWindowProc(WinampProc, hwnd, umsg, wp, lp);



It seems to work
daz (or shall I call you DrO?)you will be credited if I finish and publish my plugin
jocmir is offline   Reply With Quote
Old 8th October 2003, 15:53   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
Quote:
Even though Winamp controls the DSP plugin I need to know when a file is played because I want to load a value from disk that determines the amplification level of the current song.
now it makes sense (was trying to work out what you were trying to do)

no problem about the help. i can understand not wanting to go through the spy++ method but if you know what you want then you can drop all of the other messages

mmm, interesting thing that about the id 42 when the window is put into windowshade (hadn't done that when putting the code together) so i've learnt something new

go for DrO (makes more sense in relation to the forums - though if you want you can go for anything you like )

hope the rest of it all goes well

-daz
DrO is offline   Reply With Quote
Old 8th October 2003, 16:10   #9
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
Here it comes

I thougt you might be interested ... just finished another milestone and I think the plugin is usable now.

What it does is normalizing the volume of any audio file that is played (except wma where Winamp does not allow this) in two passes: first analyze then amplify. The name is YANA (Yet Another Normalization Attempt)

-jochen
jocmir is offline   Reply With Quote
Old 8th October 2003, 16:17   #10
jocmir
Junior Member
 
Join Date: Oct 2003
Posts: 9
now where is that file? next try ...
Attached Files
File Type: zip dsp_yana031.zip (6.4 KB, 198 views)
jocmir is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump