«» Home « » El Rinconcito de Aurora [Blogspot] « » Hispanic / Latino Anti-defamation Coalition SF « » TUYA « » El Rinconcito de Aurora [Website] « » About « » Contact «»
Showing posts with label ragtime. Show all posts
Showing posts with label ragtime. Show all posts

Wednesday, December 16, 2015

Online MIDI Player with Playlists

This is an online MIDI player with playlists, I might be wrong but after searching the net, I couldn't find one. So, I'm posting it here.
It can be seen in operation on the sidebars here and here
If you are a MIDI music lover, enjoy the music and even if you are not, I'm confident you'll enjoy it too. (All the playlists together contain 1186 titles)

MIDI[?]
Christmas Music[?]

How does it work:

It's a small script which plays a random MIDI from a list every time the page loads and it does this every time which gives the impression that it is a MIDI player, which in practice it is, but tho. I call it a "Player", It really isn't one because it doesn't 'read' the length of the file, this has to be added to the list in seconds, ex. a three minute file will have a 180 seconds duration and to make sure that the whole melody is played and doesn't cut it short, I add 3 seconds to the duration, ex. 183 seconds and that is what starts the counter for the script, when the duration time has elapsed, the script goes and gets the next file by random.

So is it a MIDI "Player" Or not? Well, as far as I'm concerned, it does the job by playing MIDI files with a page-reload loop. In the original, it used "Embed" But eventually it didn't work anymore so now it uses "application/x-mplayer2" To reproduce the MIDI sequence file. And it seems to work fine, so it is sort of one.

About the playlist:

The playlist can be in the same page where the player resides, or it can be loaded in an external file, could be javascript, php, plain text or xml file, which I have not tried... Yet, But eventually I will, now that I have re-taken the task of developing it further. I load this model's playlist in a js file.

I load the player via iframes, two of them, one with the "html+js" Where I link to the "css" Which in turn links to the GIF with the Xmas graphic bckground and the other with "The Form" Which is an option menu listing the playlists, as you can see in the example above. This is one of two menus, the other contains the list of midi files with all the text i., e., song title, duration, author, download link, etc. This list is dynamically generated by the script itself.

I've been working on explaining, for those who haven't figured out, how it all works. (Funny but I've never written down anything about it, how it functions and how to make it all work out. For anyone interested in developing their own "MIDI Plyer" (Wink, wink), below please find all the code to do it.

It is relatively easy to create a playlist with a few MIDI files, but when we are talking about hundreds or even thousands of them, it becomes cumbersome, super labor-intensive and prone to make mistakes in the name of the file qmid or the path to it. I know, trust me. Hence I had to develop a process to minimize the possibility of mistakes and also in saving time in entering the most vital information, the one which without perfection, the script will not find the file, no biggie, just click "next song" and so it does and all is well except that this melody info has to be corrected (js file), the problem is compounded when there are many, many entries.

In the table below, in the tab "How to build a playlist" During the next few weeks I'll post more details of this process, which it is somewhat complicated, but it works for me. Perhaps you can find an easier way. For now, there's not a really easy way because the playlist, until I develop an easier way, has to be created by hand, literally, the info in each line is entered manually.

In this tab I'll be going into details on the process I use to expedite to create a playlist with hundreds or even thousands of MIDI files.

I use five different programs/utilities:

I had in the past the experience of when the file name or the path is entered (Not the title) one or the other is either in lower or uppercase and some systems do not like that, so to avoid this,I had to change the case of all the files before I enter them in the playlist, for this I use a program called "Name Munger" (A batch file renaming utility) To make them all lowercase) This step can be avoided by having the settings in the FTP Utility to upload and make them all lowercase or do it with Word or Excel, it works very well, but, for the sake of uniformity, I prefer to change it in the files on my HD as well.

  • The next step is key to the integrity of the filename and it's corresponding path, for this I use a utility named "Directory List &/Print" Which can list, print or export the results into html, excel, word, copy to clipboard or to a file. For this project I export it to an excel spreadsheet that I save making it's properties "Read only" And using a copy of it as workspace for the changes to be made to it.

    So far it's easy, once in the spreadsheet it can get a bit complicated but if done properly with great attention to details and an image in your mind of where (Columns) everything will go. In other words, being very careful or it is 'start all over again' by making another copy of the "Read only" spreadsheet.

    Immediately below there is a sample Dir List output to Excel using only 3 files

    Table one

    qmid path
    bossa.mid C:\data\webpages\rinconcito\audio\midi\latin\
    clypso1.mid C:\data\webpages\rinconcito\audio\midi\latin\
    copacaba.mid C:\data\webpages\rinconcito\audio\midi\latin\

    Table two -- Since for many reasons it is highly recomended to place the html+js in the 'midi' directory. This is what we want the results to look like, hence, the excel file needs to be modified in several places & ways.

    Table three -- This is how it looks after we inserted several colums, notice the white spaces in the colums, that space needs to be removed by "Search and replace" With a text editor. I use "1st page 2000" From "Eversoft" (There's a newer version) to get the results you see in the box above.

    Table four -- After romoving the spaces, this is how the code looks like.

    Table five -- And after you preview in your editor or see the html file in a browser, immediately below you can see the results and these lines plus the hundres or thousands that make up the playlist. Just copy them from your browser's screen and paste them into the JS file. Depending on how many MIDI titles we are talking about, it's better to do them in batches, I process between 300 and 500 titles per batch.

    This is what I did to get these results: Started with 2 columns and added 15 more columns for a total of 17.

    I wasn't exaggerating when I said that automating most of the data input by creating it on a spreadsheet would facilitate that task but it gets kind of complicated but it gets better due to the practice and it's not THAT complicated anymore, hence, in any event, it's very important to pay attention to detail, for instance, I just discovered an error: When you look at the name of the melody in the table immediately above, you'll notice that there's no space between the name and between the time in minutes:seconds and 'min.' as you can see => i.,e., [qname[3]="Copacabana1:00min."] Because I removed the spaces. So, how am I going to resolve this?

    Table six -- Since there's no space between 'copacabana' and '1:00' and no space between '1:00' and 'min.', I have to create them by inserting column where spaces should be, that'll make a total of 19 columns, in those columns all the way to the bottom in both I'll place this character '|', then once back in the text editor I'll erase the spaces first and then I'll replace the '|' character with a space and we'll see how it comes out.

    And presto, it worked like a charm and it only took me about 30 secs, granted, there're only three records, but it'd have been almost as fast had there been hundreds of titles.

    There are two things I have to address, formatting cells, of which I'll be getting into in the next paragraph, and 'formulas', of the latter there are two, one for the incremental number on the qmid, qname, and qtime, i.,e., qmidi[1], 2 and 3 for each of the three fields which identifies the midis, for that we entered this formula "=b1+1" (qmidi column is "A") and copied it all the way down in that column, the other one is in qtime (col "R")"=k1*1440+3" and we also copy that one all the way down that column. This formula eases the task of first, do math, 3:30 min. X 60 + 3 on each and every file, we enter the time in minutes and seconds in that format, and the formula will return 210 as it did in 'Bossanova', so, that takes care of the number of seconds. To get the duration of each MIDI, I do it by creating an alpha-numeric sorted playlist in Media Player and then go down that list clicking at each MIDI, the media player will open the file and list the duration time in minutes and seconds, that's the number you enter and the formula will do the rest. Yeah, it's like that, it's done manually but still saves a lot of time and work, wouldn't you agree?.

    Formatting: We only do that for columns "L" (Time in min & secs) the format is "Number" and the category is "Text" (This is important, otherwise the formula won't work, And "R" (Duration in seconds via formula) cell format is also "Number" But the category is also "Number" With Zero decimals.

    To give you a better idea of what goes in each column, you can view the full size screencap "OnMouseover" in the graphic below. or you can download it to view it at your leisure. (Right-click)

    Img1

    And there you have it, how to build this "MIDI Player" or you can develop your own version. Eventually I'll be working more on it, I think PHP is a great alternative, specially for creating playlists by reading directly in the directories.

  • WOW! I never expected thia post to be this large, but it is as big as it needed to be. As I said earlier, I have this script since the mid/late 90s and I had never have written about it or how it works. I know most of you will say, "Thta's a lot of work" Indeed it is but as I also said, I love MIDIs and Xmas music, jazz, ragtime, etc. and I have MIDIs in just about every genre, including commercials, shows, movie themes, bachata, ballads (50s), boleros, cumbia, reggaeton, et al and I plan to add them to the player.

    Well, all that's left for me to do is to wish you all the best for your outcomes on whatever endeavor you are engaged in.

    Happy holidays and a most prosperous new year 2016 and beyond.

    "Magical Template" designed by Blogger Buster