Zxpand+ with Midi.

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

Re: Zxpand+ with Midi.

Beitrag von siggi » 24.05.2018, 20:29

Hi Moggy
some more input from a MIDI-expert is needed :mrgreen:
I downloaded some midi files from there:

http://www.cosmosfactory.org/rocky_horror_midi.shtml

My midi-player plays some songs at correct speed, some are played extremely slow. I found, that those songs not played correctly do not contain any TEMPO setting. So they are played too slow (192 beats per min -> 312500 usec/beat). But the windows media player plays them at correct speed!
Maybe it has a default setting, which my player does not have?
Or is there other information in the midi file, which could be used to set the correct tempo and which is not evaluated by my player?

The first midi file (SCI-FI.mid) is played too slow, the second (DAMMIT.MID) is played at correct speed:
Horror.zip
(32.32 KiB) 31-mal heruntergeladen
Regards
Siggi
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Datenkraken bitte nicht füttern!

Benutzeravatar
tokabln
User
Beiträge: 1461
Registriert: 10.11.2013, 00:24
Wohnort: D, Berlin (Mariendorf)

Re: Zxpand+ with Midi.

Beitrag von tokabln » 24.05.2018, 22:00

Hi siggi,

maybe the following link is of use for you...

http://sites.uci.edu/camp2014/2014/05/1 ... idi-files/
Lieben Gruß Torsten
BMZ MFA, ZX80Core, AX81, ZX81, ZX81NU, Spectrum+, Harlequin, VG8010, Amstrad NC100, Cambridge Z88, C64, C128D, Amiga 500 & 1200, Atari Portfolio, HP200LX, IBM PC5155, TP755c, T41, PS/2 (Model 40SX), PS/2E, Accura 101, Apple //e

Benutzeravatar
tokabln
User
Beiträge: 1461
Registriert: 10.11.2013, 00:24
Wohnort: D, Berlin (Mariendorf)

Re: Zxpand+ with Midi.

Beitrag von tokabln » 24.05.2018, 22:08

Beside two meta events that are related to each other, while I'm not sure if you are using these in your program.

Tempo
FF 51 03 tt tt tt

The tempo is specified as the Number of microseconds per quarter note, between 1 and 16777215. A value of 500000 (07 A1 20) corresponds to 120 quarter notes ("beats") per minute. To convert beats per minute to a Tempo value, take the quotient from dividing 60,000,000 by the beats per minute.

NOTE: If there are no tempo events in a MIDI file, then the tempo is assumed to be 120 BPM.

Das sollte Deine Frage beantworten :mrgreen:

In a format 0 file, the tempo changes are scattered throughout the one track. In format 1, the very first track should consist of only the tempo (and time signature) events so that it could be read by some device capable of generating a "tempo map". It is best not to place MIDI events in this track. In format 2, each track should begin with at least one initial tempo (and time signature) event.


Time signature
FF 58 04 nn dd cc bb

Time signature is expressed as 4 numbers. nn and dd represent the "numerator" and "denominator" of the signature as notated on sheet music. The denominator is a negative power of 2: 2 = quarter note, 3 = eighth, etc.

The cc expresses the number of MIDI clocks in a metronome click.

The bb parameter expresses the number of notated 32nd notes in a MIDI quarter note (24 MIDI clocks). This event allows a program to relate what MIDI thinks of as a quarter, to something entirely different.

For example, 6/8 time with a metronome click every 3 eighth notes and 24 clocks per quarter note would be the following event:

FF 58 04 06 03 18 08

NOTE: If there are no time signature events in a MIDI file, then the time signature is assumed to be 4/4.

In a format 0 file, the time signatures changes are scattered throughout the one track. In format 1, the very first track should consist of only the time signature (and tempo) events so that it could be read by some device capable of generating a "tempo map". It is best not to place MIDI events in this track. In format 2, each track should begin with at least one initial time signature (and tempo) event.
Lieben Gruß Torsten
BMZ MFA, ZX80Core, AX81, ZX81, ZX81NU, Spectrum+, Harlequin, VG8010, Amstrad NC100, Cambridge Z88, C64, C128D, Amiga 500 & 1200, Atari Portfolio, HP200LX, IBM PC5155, TP755c, T41, PS/2 (Model 40SX), PS/2E, Accura 101, Apple //e

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

Re: Zxpand+ with Midi.

Beitrag von moggy » 25.05.2018, 00:42

Hi Siggi.

Your problem is a simple one so don't get too hung up on on technobabble re quarter notes etc.

If you like I can go into which method of pulses per quarter to use for a given file and lots of other unwanted crap or just cut to the chase.

Firstly a midi file with no tempo information is not assumed to be 120bpm that is just the default tempo a sequencer adopts when no tempo is encountered likewise with time signature and is meaningless in most cases as when the file was originally created it could have been at 10,000 bpm but in the absence of tempo data it will show a 120bpm playback tempo but will in fact be playing at 10,000 bpm! Time signatures like any other data are not automatically scattered through the track in any format,they are placed at what ever point in the composition the composer decides to put them.
In a single tempo/signature file the information will appear at one point only,if at a given point in the composition the tempo/signature changes then the change will show at that point and not any other and will not be scattered throughout the track.

If you doubt any of the above I will happily give you a file at 200bpm played in 3/4 waltz time. when you load that file into any player or sequencer it will report as 120bpm 4/4 common time but trust me what you hear will be a 200bpm waltz. :lol:

There are two simple remedies that can be used.

1) load the offending file file into a PC sequencer or say Rosegarden for the Pi3 then select event editor from the menu.
In this simple to use menu various data can be inserted, you need to insert a bpm tempo of choice exit the menu then re-save the midi file.

2) convert your midi file to a csv file then at the beginning of this file when read, in say wordpad look for the word Tempo and a 6 figure value that follows it. if this is absent then insert the line.. Tempo xxxxxx

An average figure to start with is around 500000. save and convert to zxm file and try it out.

If the song is too slow decrease the figure a 1000 at a time then fine tune with smaller values, too fast increase the value etc.


You have to remember Siggi that neither the Xpand player or your player works like a true midi player and cannot read varying tempos, only the initial start value. If the piece you wish to play starts the first few notes at X speed then the rest at X plus your player will still be stuck at the original start tempo so the only solution is to either play single tempo files or choose a good average for your file found by trial and error.


Also time signature has no bearing whatsoever in this case, it only exists so as to print/display a correct musical score and in no way affects playback. The format is also unimportant only the information contained within plus format 2 (like betamax) was killed at birth many years ago and you will find zero files in that format and if you did our players would not be able to play them.


I have given the file scfi an average start tempo which you can alter to taste.
Dateianhänge
sci-fi.csv
(77.53 KiB) 29-mal heruntergeladen

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

Re: Zxpand+ with Midi.

Beitrag von siggi » 25.05.2018, 21:40

Hi Moggy
thanks for that information.
moggy hat geschrieben:
25.05.2018, 00:42
... encountered likewise with time signature and is meaningless in most cases as when the file was originally created it could have been at 10,000 bpm but in the absence of tempo data it will show a 120bpm playback tempo but will in fact be playing at 10,000 bpm!
...
If you doubt any of the above I will happily give you a file at 200bpm played in 3/4 waltz time. when you load that file into any player or sequencer it will report as 120bpm 4/4 common time but trust me what you hear will be a 200bpm waltz. :lol:
I think, that confusion of 120 bpm vs. 10000 bpm is caused by using the same unit of "bpm" for 2 different things. If we would use the unit "bpm" for the tempo of the "music" as created by the the composer (120bpm), and if we would use a different unit for the "sampling rate" (10000 ???), which is used to describe the music within a MIDI data stream, then there would be less confusion ...
There are two simple remedies that can be used.
Of course I could "patch" the midi file.
But the windows media player can play that song correctly without any patch! What does it do to get the correct speed? Maybe my player then could do the same????
Does it use AI to evaluate the complete song to select an appropriate TEMPO (like you and your NI do :) )? Or does it use (fixed?) defaults for TEMPO? Any idea what my player could do to get to the same results?
You have to remember Siggi that neither the Xpand player or your player works like a true midi player and cannot read varying tempos, only the initial start value. If the piece you wish to play starts the first few notes at X speed then the rest at X plus your player will still be stuck at the original start tempo ...
Maybe you remember that my midy player also processes further TEMPO meta-events within the midi data stream to adapt the speed? ;)
Or do you mean something different?

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

Datenkraken bitte nicht füttern!

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

Re: Zxpand+ with Midi.

Beitrag von siggi » 26.05.2018, 10:45

Problem solved! :mrgreen:

There was an error in my player in the initial calculation of the default tempo, derived from the BPM setting in the midi track. Thus the player played at wrong speed when using the defaults and at correct(*) speed after the first (and following) TEMPO meta-event.

Now "patching" of midi files is no more necessary :D
Siggi

(*) compared to the win media player
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Datenkraken bitte nicht füttern!

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

Re: Zxpand+ with Midi.

Beitrag von moggy » 26.05.2018, 14:21

Good to hear the player is now correct and apologies over my confusion about your player reading multi tempo,I confused it with the Xpand player which is single tempo only. :oops:

One thing I have to confess is that never having needed to use a converted file before (CSV) only midi files.
I have found that upon conversion some of the tempo's involved seem "wrong" musically speaking, almost as if something is happening during conversion.

Older sequencers would record a file with a clock resolution of 96 ticks per 1/4 note whereas these days the resolution can be in the 1000's so given that different files will have different resolutions I'm wondering does the midi2csv program take this into account or does it convert at a fixed resolution thus leaving some files needing tempo correction? I say this as the only time the tempo seems wrong is after conversion to csv, the original midi file playing correctly in media player or sequencers etc.

Some of the problem also lies in how the files were created in the first place.

If the composer set a correct tempo in his/her sequencer, say 160 BPM and recorded each track by playing live to the metronome then upon replay the song would play back correctly at 160 BPM in the sequencer/media player and when converted to csv would also play correctly and print a score correctly. A lot of composers however would leave the sequencer set at a default of 120 BPM and record the tracks by playing into the sequencer "freestyle" which musically speaking could be anything up to say 300 BPM but will still playback correctly in the sequencer/player due to the notes time stamp, the 120 BPM would only come into effect if you try to print a score of the piece which would result in far too many notes per measure as the original recording is musically speaking 300 BPM but recorded at 120 BPM!!

Confusing I know but I'm sure it is these kind of freestyle recorded pieces that misi2csv struggles with insofar as when it meets the default 120 BPM tempo it regards the file as having been recorded metronome correctly at that speed and not a loose freestyle speed and alters the notes time stamps during conversion resulting in the incorrect tempos I have come across or it could also be midimash that does something with these files when converting to zxm?

All this is guesswork on my part and I could be just talking my usual rubbish!! :lol:

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

Re: Zxpand+ with Midi.

Beitrag von siggi » 26.05.2018, 14:34

Hi Moggy
does this timing problem also affect the conversion from midi format 1 to 0? I need at best that format conversion for my player, not via CSV files.
Mein ZX81-Web-Server: online seit 2007
http://zx81-siggi.endoftheinternet.org/index.html

Datenkraken bitte nicht füttern!

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

Re: Zxpand+ with Midi.

Beitrag von moggy » 26.05.2018, 15:42

siggi hat geschrieben:
26.05.2018, 14:34
Hi Moggy
does this timing problem also affect the conversion from midi format 1 to 0? I need at best that format conversion for my player, not via CSV files.
Apologies again Siggi I forgot your player uses the real thing not a conversion. :oops:

From a format point of view regard type 0 as a streaming or playing format which was necessary back then when CPU's were very slow and type 1 as one used for ease of editing via a sequencer. the information contained in one should be identical in the other when converted.

Type 0 is a single track consisting of a header with data for all 16 channels followed by the note information, great for playing but hard to edit which is why most PC based sequencers show this type of file as a type 1 when loaded up so as to ease editing, the original Cubase sequencer for the Atari Ste however will load and show it as a single track.

Type 1 has all 16 channels and their data listed separately which is great for editing but hard for slower players to read analyse then play.

As stated earlier the conversion from 1 to 0 merely creates 1 track from 16 separate ones however no information should be changed lost etc.

Antworten