Skip to Content
It is currently July 6th, 2022, 8:06 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: July 20th, 2004, 6:36 am 
Offline
Junior User
Junior User

Joined: November 17th, 2003, 10:52 am
Posts: 27
Hi guys,

First up, when I first announced I had written one of these and was testing it I was inundated with people asking for it. Unfortunately I was having huge problems with memory leaks which I couldn't track down, and was VERY reluctant to letit go out, so HUGE, MASSIVE apologies to all those who asked me for it and I said "in a few weeks" and then never delivered. This was the reason why.

Anyway, the problem seems tohave been sorted with the release of v2.8.1, and I have had this script running now for a few weeks continuosly without the need for a reboot, so hopefully *touch wood* all is fixed, so here are the details for everybody to try out and let me know what you think.

A bit of background is required first I think. Many peope in the dance sector broadcast continuopus mixes. For legal reasons we are required to display the track name/artist for each and every track in that mix. One way to do this would be to split the mix into seperate files. However, there seems tobe no way at the moment that allows the files to be played back to back without either a gap between tracks, or the mix sounding all rubbish (not good when you are trying to showcase yourself as a DJ!!!). So, the other option is to keep the mix as one long file and change the track title, which is what I have done here!

OK, so theres a little bit of work required to set it up. first up youneed a new table in the SAM database. Here is the SQL to create it:

Code:
CREATE TABLE `track_list` (
  `mix_id` mediumint(4) default NULL,
  `artist` varchar(50) default NULL,
  `title` varchar(50) default NULL,
  `time` mediumint(7) default NULL
) TYPE=MyISAM;


As you can see, this creates a table called "track_list" with the following fields:
mix_id: this is equal tothe song_id within SAM
artist: the artist ofthe track
title: the title of the track
time: the time the track starts (in MILISECONDS!!!)

This table will need to be populated for each mix you have within SAM. The way I do it is using personalised php scripts on my website which the DJs have to submit a tracklisting before they can upload their mix to me. Theres no point me posting these up as they are personalised to my site and the way I work. However, there are many other ways such as phpmyadmin etc.

So, now you have the table created, and all your mix info is inserted you are ready to rock n roll!! Heres the PAL script, just copy/paste over to your own file and add to your script listing withing SAM:

Code:
PAL.Loop := True;
PAL.MemoryLeakWarning := True;

{declares variables}
var ds_currentid: TDataSet;
var currenttrack: TDataSet;
var currentid: Integer;
var currentmix: TDataSet;
var cur_time: integer;
var Song : TSongInfo;
var nexttrack: TDataSet;
var nexttime :String;
var temp_hour : Float;
var temp_min : Float;
var temp_sec : Float;
var str_hour : string;
var str_min : string;
var str_sec : string;
var temp_nexttime : Integer;
var A : TPlayer;

PAL.LockExecution;
A := ActivePlayer;

nexttime := '+0:00:20';

{Gets the song ID of the currently playing mix from the historylist}
ds_currentid := Query('SELECT MAX(ID) FROM historylist', [], TRUE);
currentmix := Query('SELECT * FROM historylist WHERE ID = :id ORDER BY date_played DESC LIMIT 1', [ds_currentid['max(ID)']], TRUE);
currentid := currentmix['songID'];

{Gets the cursor time for the mix playing}
cur_time := A.CurTime;

{Gets the track info from the databse - Note: the track_list table has to be created and populated}
currenttrack := Query('SELECT * FROM track_list WHERE (mix_id = :currentid) AND (time <= :time) ORDER BY time DESC LIMIT 1', [currentid, cur_time], TRUE);

{Works out length of track}
nexttrack := Query('SELECT * FROM track_list WHERE (mix_id = :currentid) AND (time > :time) ORDER BY time ASC LIMIT 1', [currentid, cur_time], TRUE);

{Checks that there is track info for the mix}
If not currenttrack.IsEmpty then
      begin
            Song := TSongInfo.Create;

            {Creates the appropriate artist and title fields in the desired format}
            Song['artist'] := currentmix['artist'] + ' - ' + currentmix['title'];
            Song['title']  := '[' + currenttrack['artist'] + ' - ' + currenttrack['title'] + ']';

            WriteLn(Song['artist'] + Song['title']);

            {Update song information}
            Encoders.SongChange(Song);
           
            temp_nexttime := nexttrack['time'];
           
            {works out length of track}
            If nexttrack.IsEmpty then
               temp_nexttime := A.duration;


      end
Else
      begin
            WriteLn('Tracklisting for ' + currentmix['artist'] + ' - ' + currentmix['title'] + ' needs uploading' );
            temp_nexttime := A.duration;
      end;

{converts the time of the track from ms into the format '+hh:mm:ss'}
temp_hour := INT((temp_nexttime - cur_time)/(1000*60*60));
temp_min := INT(FRAC((temp_nexttime - cur_time)/(1000*60*60))*60);
temp_sec := INT(FRAC((FRAC((temp_nexttime - cur_time)/(1000*60*60)))*60)*60);

If (temp_hour < 10) then
   str_hour := '0' + FloatToStr(temp_hour)
else
   str_hour := FloatToStr(temp_hour);

If (temp_min < 10) then
   str_min := '0' + FloatToStr(temp_min)
else
   str_min := FloatToStr(temp_min);

If (temp_sec < 10) then
   str_sec := '0' + FloatToStr(temp_sec)
else
   str_sec := FloatToStr(temp_sec);

nexttime := '+' + str_hour + ':' + str_min + ':' + str_sec;
           
Song.Free;
ds_currentid.Free;
currentmix.Free;
nexttrack.Free;
currenttrack.Free;
Encoders.Free;
A.Free;

PAL.UnlockExecution;

{Waits either for next track or for end of mix before re-checking}
PAL.WaitForTime(nexttime);


If you have any questions then post them below and I'll do my best to answer them, and if you have any suggestions for the code etc then again, let me know.

Hope this is of use to a few of you.


Top
 Profile  
Reply with quote  
PostPosted: July 20th, 2004, 8:18 am 
Offline
Experienced User
Experienced User

Joined: April 17th, 2004, 5:25 am
Posts: 297
Location: Switzerland
Should be possible to use this script for re-broadcasting another stream, hmm?
All I have to do is change the "song-id" by hand to match...

Thank you! :D

_________________
Image


Top
 Profile  
Reply with quote  
PostPosted: July 20th, 2004, 2:57 pm 
Offline
Alumni
Alumni

Joined: February 11th, 2003, 5:55 pm
Posts: 492
Location: Texas USA!!
PLEASE make sure to post this all in the Kwowledge base for other users to share :)

Thanks for your hard hard work and the Excellent script!

Bryan

_________________
Bryan Payne, CEO
www.spacialaudio.com
www.spacialnet.com
www.audiorealm.com


Top
 Profile  
Reply with quote  
 Post subject: MS SQL Script
PostPosted: March 14th, 2006, 10:43 pm 
Offline
New User
New User

Joined: March 14th, 2006, 10:28 pm
Posts: 10
Here is the MS SQL script equivalent. Just minor tweaks:

PAL.Loop := True;
PAL.MemoryLeakWarning := True;

{declares variables}
var ds_currentid: TDataSet;
var currenttrack: TDataSet;
var currentid: Integer;
var currentmix: TDataSet;
var cur_time: integer;
var Song : TSongInfo;
var nexttrack: TDataSet;
var nexttime :String;
var temp_hour : Float;
var temp_min : Float;
var temp_sec : Float;
var str_hour : string;
var str_min : string;
var str_sec : string;
var temp_nexttime : Integer;
var A : TPlayer;

PAL.LockExecution;
A := ActivePlayer;

nexttime := '+0:00:20';

{Gets the song ID of the currently playing mix from the historylist}
ds_currentid := Query('SELECT MAX(ID) MIXID FROM historylist', [], TRUE);

currentmix := Query('SELECT TOP 1 * FROM historylist WHERE ID = :id ORDER BY date_played DESC', [ds_currentid['MIXID']], TRUE);


currentid := currentmix['songID'];

{Gets the cursor time for the mix playing}
cur_time := A.CurTime;

{Gets the track info from the databse - Note: the track_list table has to be created and populated}
currenttrack := Query('SELECT TOP 1 * FROM track_list WHERE (mix_id = :currentid) AND (time <= :time) ORDER BY time DESC ', [currentid, cur_time], TRUE);

{Works out length of track}
nexttrack := Query('SELECT TOP 1 * FROM track_list WHERE (mix_id = :currentid) AND (time > :time) ORDER BY time ASC', [currentid, cur_time], TRUE);

{Checks that there is track info for the mix}
If not currenttrack.IsEmpty then
begin
Song := TSongInfo.Create;

{Creates the appropriate artist and title fields in the desired format}
Song['artist'] := currentmix['artist'] + ' - ' + currentmix['title'];
Song['title'] := '[' + currenttrack['artist'] + ' - ' + currenttrack['title'] + ']';

WriteLn(Song['artist'] + Song['title']);

{Update song information}
Encoders.SongChange(Song);

temp_nexttime := nexttrack['time'];

{works out length of track}
If nexttrack.IsEmpty then
temp_nexttime := A.duration;


end
Else
begin
WriteLn('Tracklisting for ' + currentmix['artist'] + ' - ' + currentmix['title'] + ' needs uploading' );
temp_nexttime := A.duration;
end;

{converts the time of the track from ms into the format '+hh:mm:ss'}
temp_hour := INT((temp_nexttime - cur_time)/(1000*60*60));
temp_min := INT(FRAC((temp_nexttime - cur_time)/(1000*60*60))*60);
temp_sec := INT(FRAC((FRAC((temp_nexttime - cur_time)/(1000*60*60)))*60)*60);

If (temp_hour < 10) then
str_hour := '0' + FloatToStr(temp_hour)
else
str_hour := FloatToStr(temp_hour);

If (temp_min < 10) then
str_min := '0' + FloatToStr(temp_min)
else
str_min := FloatToStr(temp_min);

If (temp_sec < 10) then
str_sec := '0' + FloatToStr(temp_sec)
else
str_sec := FloatToStr(temp_sec);

nexttime := '+' + str_hour + ':' + str_min + ':' + str_sec;

Song.Free;
ds_currentid.Free;
currentmix.Free;
nexttrack.Free;
currenttrack.Free;
Encoders.Free;
A.Free;

PAL.UnlockExecution;

{Waits either for next track or for end of mix before re-checking}
PAL.WaitForTime(nexttime);


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2006, 1:02 pm 
Offline
Senior User
Senior User

Joined: May 1st, 2005, 7:47 pm
Posts: 88
Location: Bern, Switzerland
Hi Guys

Excellent Script - thanks a lot - there were many people looking for this I suppose (well, at least I was..), and not only DJ's with own DJ-Sets.

What I was asking for is whether it would be very complicated to extend this script with a CUE-Sheet (a simple ASCII based File) as a common base for track-information within a DJ-mix. Many DJs work with CUE sheets (and also CD Extractors create CUE Sheets when "mix-CD's" are ripped to MP3s.

What would be the impact on doing this? I believe instead of having a separate table, the PAL would have to parse those informations out of the .CUE sheet on the harddisk, right?

Any ideas on your end?

Alex


Top
 Profile  
Reply with quote  
PostPosted: August 16th, 2006, 7:16 am 
Offline
Junior User
Junior User

Joined: April 22nd, 2006, 5:16 pm
Posts: 27
Code:
CREATE TABLE `track_list` (
  `mix_id` mediumint(4) default NULL,
  `artist` varchar(50) default NULL,
  `title` varchar(50) default NULL,
  `time` mediumint(7) default NULL
) TYPE=MyISAM;

where do i do this sry all new to the mysql so i have no clue what to do with this or how to make it do it?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2006, 8:30 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 10571
Location: Denver, CO
Stick this into a PAL and run it
Code:
ExecSQL('CREATE TABLE IF NOT EXISTS track_list' +
'(mix_id mediumint(4) default NULL,  artist varchar(50) default NULL,  title varchar(50) default NULL,  time mediumint(7) default NULL)',[]);

_________________
- Rob Oyler, SVS
Image


Top
 Profile  
Reply with quote  
 Post subject: Continuous mix script
PostPosted: February 6th, 2008, 3:49 pm 
Offline
New User
New User

Joined: March 14th, 2006, 10:28 pm
Posts: 10
This script works great for my mixes and keeps me in compliance with licensing.

Thanks brother.


Top
 Profile  
Reply with quote  
PostPosted: July 12th, 2021, 12:19 pm 
Offline
Senior User
Senior User

Joined: January 2nd, 2004, 1:07 pm
Posts: 186
Location: Cordoba, Argentina
I'd connect mix details with SAM's songlist table using the songID attribute and include exact starting times of each song in the mix detail table so their information is whown exactly in the time they are playing. Or even easier for the DJ, I'd include mix details in SAM's songlist table, info attibute, with format [track] [mm:ss] [artist] [title] (similar to a .cue file) and use this information in PAL.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group