Zxpand+ with Midi.

ZX-Team Forum
Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 13.03.2018, 21:26

Hi Moggy
here seems to be one of the 1000 songs, which are played at the wrong speed by Midi/Micromash (much too fast) :shock:
Movie_Themes_-_Chariots_of_Fire_-_by_Vangelis.zip
(7.86 KiB) 31-mal heruntergeladen
Do you agree?
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 13.03.2018, 21:54

Yes indeed too fast but we are in luck it is a single tempo file with the wrong tempo I'm working on it now....


EDIT. Back again.

In the zip file you will find 1) the original text file after conversion and 2) the same file with altered tempo.
also the ZXM file which works on the Xpand.

While you examine these I will type out a way for you to alter these single tempo files that play incorrectly with an explanation of why they are like this... Back soon.
Dateianhänge
Van-g.zip
(99.99 KiB) 22-mal heruntergeladen

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 13.03.2018, 23:02

So how to alter tempo?

If you examine the text file created in the first part of the conversion you will see early on in the file something like this....

Tempo 450000.

If the file is single tempo then we are in luck because we can alter it to what we like. It will be either faster or slower after you make an alteration. If the file has multiple tempos then we are out of luck because this is part of the "conductor track" and like a real human conductor will speed up or slow down the music at various points.
When playing on the zeddy if the file has multiple tempos I have found that after it is converted by MIDIMASH only the first tempo in the list is obeyed. the rest of the different tempos are either ignored or possibly not carried across from the text file, at this moment in time I'm not sure which of these things is happening.

So how do we alter the tempo and why are some single tempo files too fast or too slow to begin with?

To answer the second part first, the reason for these slight tempo differences I believe is that the files were created using SMPTE( Society of Motion Picture and Television Engineers) timecode which is the common way of doing things when creating MIDI compositions and will play correctly in say media player or a PC sequencer, but the conversion process is, I think, using what we call MIDI time code or beat code which has a different timing resolution and the files can sometimes sound too fast/slow.

To alter the tempo, simply list the text file in say notepad and alter the the tempo value.
You will notice it is usually a six figure number. In our example 450000, if the number is increased then the tempo will slow down and if it is decreased then the tempo will speed up.

A coarse adjustment should be done first concentrating on the first two figures only so for example make 450000 become 650000 to slow it down or 350000 to speed it up. concentrate on the remaining digits only for very fine tuning then save the file with the changes made.

In the Vangellis file I believe the default was 500000 which I changed to 830000 for a rough tempo adjustment,it should also be noted that this file will have slightly odd sounding hand claps where a snare drum should be playing. This is because the file is a GS(General Standard) not a GM(General MIDI) file which takes advantage of the extra percussion sounds a GS module provides by using ordinary note data to play a different tone bank so when we play it back on our GM modules instead of the correct snare drum sounding, the note data uses the standard GM sound bank and you have hand claps or other strange percussion instead of the drum.
Just one of the many joys of MIDI I'm afraid.

The only downside for xpand users is that this tempo adjustment alters the block size making it too large in some cases and no successful tempo change is possible but this should be no problem with Siggi's method.

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 14.03.2018, 11:39

Hi Moggy
here are some windows batch files.
CONV.BAT converts one midi file into a ZXM file
CONVALL converts all midi files of the current directory into ZXM files (calling CONV.BAT)
CONVCVS.BAT converts one CVS file (generated by MIDICVS) into a ZXM file.
convall.zip
(649 Bytes) 21-mal heruntergeladen
Maybe they avoid further pain in essential parts of your body :wink:

Siggi

Vangelis in "slow motion" sounds good :mrgreen:
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 14.03.2018, 13:24

Great work! :mrgreen:
(Does it take into account the ZXpand block size limitation?)


Vielen Dank dafür, Siggi.

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 14.03.2018, 13:38

The batch files call the original EXE files (like MIDIMASH), thus do not know anything about block sizes.
The EXE files must be in the same directory (or in the search path).

Gern geschehen
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 14.03.2018, 13:52

Sorry to sound stupid Siggi but if I may trouble you one more time?

I am not very good with PC and command line so could you please give me instruction on how to use the batch files etc as programming is not my strong point. :oops:

Regards.

Moggy.

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 14.03.2018, 14:03

Put them into the same directory which contains your midi files and midicvs.exe and midimash.exe.
At command line you have to enter the batch file name and midi or cvs file to be converted:
conv my_midi_file

or

convcvs my_cvs_file

The "convall" batch file does not expect a file name, so just enter
convall

But you could also click at "convall.bat", if you have been gone to the correct directory using windows file explorer:

conv.jpg
conv.jpg (68.21 KiB) 1230 mal betrachtet

HTH
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 14.03.2018, 14:42

IT TOOK ME NEARLY A MONTH COVERT A 1000 FILES BY HAND.
THE BATCH FILE JUST DID 100 MORE IN THE BLINK OF AN EYE!! :shock: :shock:

Vielen, vielen Dank dafür, Siggy. Ich werde jetzt den Rest meiner Sammlung konvertieren. (bitte entschuldige meine schlechte Übersetzung)



Best Regards.

Moggy.
Dateianhänge
images.jpg
images.jpg (11.35 KiB) 1219 mal betrachtet

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 14.03.2018, 21:41

moggy hat geschrieben:
13.03.2018, 23:02
If the file has multiple tempos then we are out of luck because this is part of the "conductor track" and like a real human conductor will speed up or slow down the music at various points.
When playing on the zeddy if the file has multiple tempos I have found that after it is converted by MIDIMASH only the first tempo in the list is obeyed. the rest of the different tempos are either ignored or possibly not carried across from the text file, at this moment in time I'm not sure which of these things is happening.
Here is one of the files, having a lot of tempo :wink:
Pink_Floyd_-_Shine_On_You_Crazy_Diamond.zip
(89.04 KiB) 27-mal heruntergeladen
Sounds ugly when played by my Zeddy .... :(
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 14.03.2018, 23:44

This is a good example of a badly sequenced MIDI file because if you search the CSV file you will see the creator hasn't even bothered to include a tempo setting and is relying on note spacing to give tempo effects much like the method used by a tracker.

Also remember if any file has a single tempo in the CSV listing then it can be altered for correct speed, it is the multi tempo stuff that is the problem which I will try and sort out with Charlie.

Apart from the speed other reasons why this may sound bad is...

A) In the listing it is a GS file meant to be played on a GS enabled module with extra tone banks not a GM file.

B) This song when played has a constant "drone" sound nearly all the way through and unfortunately the chip that our little synth uses has a very small sized sample bank which means quick single notes will sound ok but any kind of long drawn out note means there will be times when you can hear the join in the sample as it loops plus because of the chips limitations not all of the instruments are accurate in their reproduction ( the saxophones are dreadful ) and should be judged as so.

C) It is to be honest a very badly put together song and poorly sequenced.

The unfortunate thing about MIDI is that like the internet there is a great deal of rubbish out there and you have to dig deep to find the good stuff, and by that I mean songs that are well constructed even if they are not to our musical taste.

I happen to have a few versions of this track which may or may not be ok so feel free to experiment with them.

Also a link to a site which concentrates on jazz which may not be to your taste but I have found most of the files to be well constructed and some that I cannot convert due to the Xpand block size limitation which should be ok for you. :D

Once again,Siggi thank you for the batch file converter, my life just got a whole lot easier. :lol:

http://www.thejazzpage.de/index1.html
Dateianhänge
PINKFL~1.zip
(113.3 KiB) 31-mal heruntergeladen

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 15.03.2018, 08:00

moggy hat geschrieben:
14.03.2018, 23:44
Also remember if any file has a single tempo in the CSV listing then it can be altered for correct speed, it is the multi tempo stuff that is the problem which I will try and sort out with Charlie.
:D
Good luck!
B) This song when played has a constant "drone" sound nearly all the way through and unfortunately the chip that our little synth uses has a very small sized sample bank which means quick single notes will sound ok but any kind of long drawn out note means there will be times when you can hear the join in the sample as it loops plus because of the chips limitations not all of the instruments are accurate in their reproduction ( the saxophones are dreadful ) and should be judged as so.
Do you mean by "our little synth" the matchbox sized board? I have a YM PSR 220 (like Paul has) at the other end of the midi line (I wanted to have an appropriate counterpart to the Zeddy). That "drone" is no problem ....
C) It is to be honest a very badly put together song and poorly sequenced.
But from the point of view of a non-MIDI-expert it sounds good (why can a PC play it "correctly"?) :wink:
I happen to have a few versions of this track which may or may not be ok so feel free to experiment with them.
Thanks. But micromash dies during conversion of one file
"Converting "SHINE6-7.mid"
Track 1 header is invalid."

Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 15.03.2018, 12:01

Hi Moggy
I have found the source code of a small midiplayer (written in C) for an 8 MHz ATmega8:
https://www.mikrocontroller.net/topic/48542

If we could port that player to a ZX81, we would not need a PC or MIDIMASH any more.
But there is a restriction, written by the author:
Author hat geschrieben: // Software:
// MMC-Driver from alp_mp3 - Open Source Atmel AVR based MP3 Player (modified, though)
// My own MIDI-File-Parser (Format 0 only)
// Compiles with WinAVR plus AVRStudio 4
Would "Format 0" be sufficient?

Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 15.03.2018, 12:29

A few quick answers, Siggi.

Speaking as a dedicated Yamaha user... PSR-220 EXCELLENT CHOICE! :mrgreen:

The nanosynth is ok but a very basic MIDI instrument.

When you say play it correctly I assume you mean play it at the correct speed?

To be honest I find some of the tempos created by the conversion program very odd and do not relate to the real thing.
I have had to correct many of my files that play ok on PC but are either too fast/slow after conversion for the zeddy,I can only assume something is amiss in the conversion algorithm.

This brings me to your last post.

Format 0 is an excellent choice. :D

There are three formats. MIDI 0,1,2.

MIDI 2 is no longer used so is of no concern.

MIDI 1 has all the instruments as separate tracks. So when viewed in a sequencer you would see the piano track, bass track ,drum track etc vertically down the screen and because they are separate they are easier to work on.

MIDI 0 has all the information on just the one track and is the preferred format for MIDI players so would be good for zeddy.

When you get a midi file it is not easy to tell the format so all you have to do is put the files into a format converter which I can provide and the problem is solved. :D

I look forward to this new player very much. :D

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 15.03.2018, 14:54

moggy hat geschrieben:
15.03.2018, 12:29
I look forward to this new player very much. :D
Please note, what I have written above: "If we could ...."
The Atmel controller runs at 8 MHz, the Zeddy at 3,25 MHz.
But the Zeddy has a FAST mode ...
:mrgreen:
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 17.03.2018, 15:14

Hi Moggy
a lot of my midi files seems to be of type 1 and are not accecpted by the player above.

Code: Alles auswählen


		if (!checkstring("MThd", 4))
		{
			printf("Kein Midi File.\n");
			exit (EXIT_FAILURE);
		}

		checkbyte(0);
		checkbyte(0);
		checkbyte(0);
		checkbyte(6);
		checkbyte(0);
		checkbyte(0);
		checkbyte(0);
		checkbyte(1);
		gl_timeset = fetchbyte() << 8;
		gl_timeset |= fetchbyte();
It checks for type 0 and 1 track block within the file.

Where can I get that format converter? Or could you it upload here?

Thanks
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 17.03.2018, 20:08

The converter attached here has a German language read me file to help you.
Files can only be done one at a time as unfortunately the batch conversion part doesn't work but I'm sure you can fix that. 8)


Regards.

Moggy.
Dateianhänge
midi conv.zip
(1.2 MiB) 21-mal heruntergeladen

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 18.03.2018, 12:17

moggy hat geschrieben:
12.03.2018, 15:49
Hi Siggi.

Many thanks for taking the time for this. :D

The reason I chose this file is because the xpand struggles badly with it when converted and I was hoping that your method of playing the file would cure it.

The file should take about 16 minutes when played via a PC based sequencer which will read the conductor track and any controller information separately from the note information.
Current state is: the new "True MIDI-Player" (using Midi-Files Version 0) is playing that within approx. 21 minutes ...
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 18.03.2018, 14:33

siggi hat geschrieben:
18.03.2018, 12:17
moggy hat geschrieben:
12.03.2018, 15:49
Hi Siggi.

Many thanks for taking the time for this. :D

The reason I chose this file is because the xpand struggles badly with it when converted and I was hoping that your method of playing the file would cure it.

The file should take about 16 minutes when played via a PC based sequencer which will read the conductor track and any controller information separately from the note information.
Current state is: the new "True MIDI-Player" (using Midi-Files Version 0) is playing that within approx. 21 minutes ...
This very interesting because I get the feeling that at 21 minutes the tempo changes are being obeyed but maybe zeddy himself is just a bit slow.

This is excellent progress Siggi. :mrgreen:

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 18.03.2018, 18:03

Hi Moggy
meanwhile I have optimized the C program for speed and adapted the timing measurements, so that the runtime of the code is taken into account for MIDI delays. Now the duration is approx. 18 minutes 25 seconds :D

Concerning batch files for MIDI-file conversion: the freeware version of your program does not offer batch file support. So I cannot test anything.
If you have information about contents of such a batch file or examples: maybe I can try to adapt them, that you could test them?

Regards
Siggi

PS: Maybe Charlie could adapt my new player for usage with ZxPand?
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 18.03.2018, 22:17

Apologies Siggi I posted wrong program!! :oops:

This is the one you need which converts a lot of files at once, taken from here...

http://www.jososoft.dk/yamaha/software/ ... /index.htm

So 18 minutes means you are getting closer which is excellent (16m :46s is the target) and means the tempos are being read. :D

I will contact Charlie but I know he is very busy at the moment.


Again super work. :mrgreen:
Dateianhänge
midiformat.zip
(46.26 KiB) 20-mal heruntergeladen

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 19.03.2018, 09:36

moggy hat geschrieben:
18.03.2018, 22:17
So 18 minutes means you are getting closer which is excellent (16m :46s is the target) and means the tempos are being read. :D
Yes:

Code: Alles auswählen

			case 0x51:	// Tempo Change
					checkbyte(3);
					temp = (unsigned long)fetchbyte() << 16;
					temp |= (unsigned long)fetchbyte() << 8;
					temp |= (unsigned long)fetchbyte();
					OCR1A = temp/gl_timeset;
					setup_NMI_Timer(OCR1A);
					break;
And I identified some locations in the program, where I can save some more Z80 clock cycles. So the next version will probably be a little bit faster :wink:

And I found a problem: when the program has played the song it should come back to SLOW mode to show the result. But sometimes (depending on the song) the programs does not terminate and seems to remain in a loop in one of the cleanup routines ...

Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

moggy
User
Beiträge: 81
Registriert: 09.09.2011, 16:30

Re: Zxpand+ with Midi.

Beitrag von moggy » 19.03.2018, 15:38

The problem with a lot of MIDI files is that they don't follow what were accepted conventions of the time and were put together very poorly by composers who should have known better. :(

It was always good practice to end a song with a systems message of "all notes off" followed by a GM reset. This served the purpose of stopping the hard/soft ware sequencer or player and also resetting it for next song. Without these messages the player would play into infinity, the sequencer I use on the Pi 3 suffers this way, and is something we have to live with.

Is it possible to make an mp3 of the song Siggi? The quality is not important so mp3 in mono of a low bit rate would be sufficient just so I can confirm the player is behaving accordingly.



Regards.

Moggy.

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 19.03.2018, 23:12

Hi Moggy
I made a .OOG file (USB-Stick->ZX81->Midi->YM->Headphone-Out->Mic-In->Notebook), because my Audacity does not have a MP3 licensed module.
Hope that sounds good enough:
test.zip
(2.26 MiB) 22-mal heruntergeladen
I was not able to speed up playing any more. Maybe now the speed-limit is not given by the C program, but other parameters (like the speed of reading the file from USB stick: done by bit-banging to implement an SPI interface, which the ZX81 does not have).
Despite the speed is a little bit too slow, I think it sounds good :wink:

Regards
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Benutzeravatar
siggi
User
Beiträge: 2352
Registriert: 06.12.2005, 08:34
Wohnort: D, Hessen, tiefste Werreraa
Kontaktdaten:

Re: Zxpand+ with Midi.

Beitrag von siggi » 20.03.2018, 13:54

Hi Moggy
yesterday I played the attached song from Pink Floyd: it is played totally wrong.
The "Tempo" setting is processed, but probably not correct.

I adapted the timing (I found in the player source) from Atmel 8MHz timing (1 us clock???) to Zeddy timing (64 us clock). But it sounds ugly.
I tried to understand the time calculations used for the Atmel timing, but do not understand it. Thus I will do my own calculation now :mrgreen:

Does this site describe the MIDI timing correct?
http://www.deluge.co/?q=midi-tempo-bpm

Regards
Siggi
Dateianhänge
Pink_Floyd_-_Shine_On_You_Crazy_Diamond.zip
(89.04 KiB) 24-mal heruntergeladen
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Antworten