YM recording unstable

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.2.0

Moderators: simonsunnyboy, thothy, Moderator Team

User avatar
dma
Atari Super Hero
Atari Super Hero
Posts: 997
Joined: Wed Nov 20, 2002 11:22 pm
Location: France
Contact:

YM recording unstable

Postby dma » Sun Nov 25, 2012 10:21 am

Hi,

No matter how i try, even setting Hatari running priority to real-time, i always get some unprecise YM recording.
The music is played perfectly to the speakers, but the resulting YM log got many notes "not on the beat" (it is even more noticable on apreggios, as we're talking here about frequency changes) probably shifted by some milliseconds.

Is there a way to get something more stable?

Dal
Administrator
Administrator
Posts: 4178
Joined: Tue Jan 18, 2011 12:31 am
Location: Cheltenham, UK
Contact:

Re: YM recording unstable

Postby Dal » Mon Nov 26, 2012 6:22 am

Try:

Connect headphone out to line in (same machine or another one)
Run audio capture software (eg audacity) and configure it to use the line in as input device
Hit record in audio capture software
Run Hatari
Crop the resulting waveform as you wish
Mega"SST" 12, MegaSTE, STE: Desktopper case, IDE interface, UltraSatan (8GB + 512Mb) + HXC floppy emulator. Plus some STE's/STFM's

Hippy Dave
Atari Super Hero
Atari Super Hero
Posts: 515
Joined: Sat Jan 10, 2009 5:40 am

Re: YM recording unstable

Postby Hippy Dave » Mon Nov 26, 2012 8:50 am

Hatari appears to check the YM2149 registers once every vertical retrace
(50 or 60 or 71 Hz) to generate the .YM file. Thus, whatever 'register content'
is there at that time is used.

Maybe the .YM register capture could be synchronized to a timer for better
time resolution (Timer C maybe).

Or maybe a new .YM format could be invented by streaming the YM
registers with 'difference in time' tags.

User avatar
nativ
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4106
Joined: Mon Jul 30, 2007 10:26 am
Location: South West, UK

Re: YM recording unstable

Postby nativ » Mon Nov 26, 2012 12:38 pm

copy your ym music to a floppy and play on a real machine and record from there! :D
Atari STFM 512 / STe 4MB / Mega ST+DSP / Falcon 4MB 16Mhz 68882 - DVD/CDRW/ZIP/DAT - FDI / Jaguar / Lynx 1&2 / 7800 / 2600 / XE 130+SD Card // Sega Dreamcast / Mega2+CD2 // Apple G4

http://soundcloud.com/nativ ~ http://soundcloud.com/nativ-1 ~ http://soundcloud.com/knot_music
http://soundcloud.com/push-sounds ~ http://soundcloud.com/push-records

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Mon Nov 26, 2012 12:43 pm

Hello

recording YM regs on every VBL shouldn't cause problem when listening to the resulting YM file. Of course, you need an YM player that works at 50 Hz.
But if the music you're trying to record is using timers to produce SID like volume variations, then it won't work, because in the YM format such timer based effects need to be nearly hand edited to replace the consecutive volume variations by a single .YM command that says for example "modulate volume for voice A between 0 and 13 at 1200 Hz".

So, what kind of music are you trying to record ? Can you try with "simple" music from most games, where 99% of the time registers are changed only once per VBL.

Nicolas

User avatar
dma
Atari Super Hero
Atari Super Hero
Posts: 997
Joined: Wed Nov 20, 2002 11:22 pm
Location: France
Contact:

Re: YM recording unstable

Postby dma » Wed Nov 28, 2012 9:20 am

It's a play YM track, no soft-fx involved.

It seems i can get a more stable recording when running the emulator on second CPU only at "real time" priority.
Also it seems more (if not totally) stable when replayed with a "native player" (on the real computer), rather on than ST-Sound Windows emu-player.
Maybe this latter point is the actual reason.

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Wed Nov 28, 2012 9:36 am

Do you get similar results (stable or not) when you play a YM song recorded using Hatari and the same song recorded by someone else (I think you should be able to find a lot of YM songs on the internet) ?
Running the emulator real time or not should not affect the way YM file is recorded (especially if the output sound from Hatari at the same time is correct).
Maybe your windows player doesn't correctly support the "YM3!" format used in Hatari ? (which is not the most recent YM format)

Nicolas

User avatar
dma
Atari Super Hero
Atari Super Hero
Posts: 997
Joined: Wed Nov 20, 2002 11:22 pm
Location: France
Contact:

Re: YM recording unstable

Postby dma » Wed Nov 28, 2012 10:00 am

ST-Sound is the "original" YM emu-player, coded by Leonard, so it should be up to date with latest YM format.

I'll try recording an existing game track to compare it with an existing YM log of it (the one i've recorded so far being actually a wip track of mine), when i got time to test it.

gilles504
Atari freak
Atari freak
Posts: 69
Joined: Thu Aug 11, 2011 4:17 pm

Re: YM recording unstable

Postby gilles504 » Sat Jan 12, 2013 10:36 pm

capturing at every VBL is not perfect because you may get some aliasing of nearly 1VBL in the worst case.
a better capture would be to check 3 or 4 time a frame (at a fixed rate based on VBL refresh). And only keep the best one (to avoid capturing partial updates, ie one chanel modified and not the other, or worst, fine tune modified and not coarse).

maybe an even better capture rate is the last YM event for a while (ie track first YM event, record all as one event, wait a little time after last event and consider this was an update). a second check can be to count cycles between 2 events, this can be used as an auto detect for frequency, not always VBL based.

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: YM recording unstable

Postby FedePede04 » Sat Jan 12, 2013 10:45 pm

if it just a ym file then you can try mine ym2149 emulator i render all two millions clk for the chip :)
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

evil
Captain Atari
Captain Atari
Posts: 186
Joined: Sun Nov 12, 2006 8:03 pm

Re: YM recording unstable

Postby evil » Sun May 25, 2014 9:14 am

dma wrote:Hi,

No matter how i try, even setting Hatari running priority to real-time, i always get some unprecise YM recording.
The music is played perfectly to the speakers, but the resulting YM log got many notes "not on the beat" (it is even more noticable on apreggios, as we're talking here about frequency changes) probably shifted by some milliseconds.

Is there a way to get something more stable?


Hi,

after a couple of years, I can confirm this.
Sometimes there is a very subtle change of beat, almost not noticeable, but it's there. Happens once each 18-19 seconds or so.

A wild guess is that the YM data is duplicated (eg, the same values happens twice) after a while.
It's not easy to hear it in a normal track.

When recording to a wavefile (or movie) this problem doesn't happen.


I made the simpliest SNDH to try, it plays a beep every second note-row at speed 6, 50 Hz. So it should be a new beep each 12 vbl or so I guess.

Here is the YM-dump: https://dl.dropboxusercontent.com/u/314 ... k/tempo.ym
Here is a WAVE dump: https://dl.dropboxusercontent.com/u/314 ... /tempo.wav
Here is the original SNDH (loadable in maxYMiser): https://dl.dropboxusercontent.com/u/314 ... tempo.sndh

The YM file will sound unsynced at about 4s and then again about 23s, it's quite easy to hear.
The WAVE will be fine all the time.

I've tried the YM file in my own YM-player (that I've run inside Hatari) as well as the Audio Overload program that I believe uses Leonards player. Same issue, so I rule out a player problem.

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Sun May 25, 2014 1:23 pm

Thanks for the detailled case, I can reproduce it, but unfortunatelly in that case the problem is not in Hatari but in the player.

What is happening is that the player runs using a timer, not using the VBL, and it's frequency is slighly less than 1 VBL (maybe they expected it to be at the same freq than a VBL, but a VBL is not exactly 50 Hz).
So, on each run of the player, there's a small drift of approx 150-170 cycles, which means that after ~1000 VBL (~20 sec), the player will be called 999 times but you had 1000 VBL.
As Hatari records YM data at each VBL, this is why you get a duplicated bytes in the YM file.

Can you play the same file using a player that runs in the VBL handler ? I think that if you record YM in that case it will work.

There's nothing we can do in Hatari to correct that, YM recording can only be accurate if the player runs at the same freq as the VBL. It would be very complicated to have code in Hatari to guess when the player really ran and when YM registers should be copied.

Nicolas

evil
Captain Atari
Captain Atari
Posts: 186
Joined: Sun Nov 12, 2006 8:03 pm

Re: YM recording unstable

Postby evil » Sun May 25, 2014 2:37 pm

npomarede wrote:There's nothing we can do in Hatari to correct that, YM recording can only be accurate if the player runs at the same freq as the VBL. It would be very complicated to have code in Hatari to guess when the player really ran and when YM registers should be copied.


Hi, thank you for the quick reply.

I took for granted that Hatari did this in a more low level way, eg, checking the actual YM for when there are writes there instead of hoping stuff have happened.

But cool, then there is a workaround, at least for VBL-played songs.
I did a quick test program and indeed it works. However recording from demos and games which might not use VBL, the YM-recording is still lacking.

Thanks!

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: YM recording unstable

Postby FedePede04 » Sun May 25, 2014 3:09 pm

hi
the playing problem sound easy to fix, but some of the score (tunes) are more hard to get to sound right.

first we have some scores eg. by David Whittaker they are always played at 60hz, regardless of the computer is running in PAL, so he is probably not using the vblank to play, and if you captures (sample) the register at 50HZ then they probably wont be precise.

the next problem is if a song if playing at a much higher HZ like 3DGalaxy it just sound so wrong,(but the funny thing here is that even the 3DGalaxy SNDH file sound wrong :lol: )

so for me, the best solutions, would be that one could select the sampling freq of the register from eg. 50-300 hz.
then after you could always resample the freq so it fit your need :)

but i know that would probably never happen, due to that not many is using it anymore and consider the YM file format to be dead. (but if you add it, then you would make me really glad :D :lol: )

/Peter
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

Hippy Dave
Atari Super Hero
Atari Super Hero
Posts: 515
Joined: Sat Jan 10, 2009 5:40 am

Re: YM recording unstable

Postby Hippy Dave » Sun May 25, 2014 5:53 pm

If Hatari wrote the register values out in real time when they change, there would be no aliasing.
Then constuct a YM file from the register patterns (and guess the timing later).
Another method could be to dump the YM resisters at the same rate (or fraction) as the .WAV file.

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Sun May 25, 2014 7:58 pm

Hippy Dave wrote:If Hatari wrote the register values out in real time when they change, there would be no aliasing.
Then constuct a YM file from the register patterns (and guess the timing later).

That's the whole problem : guessing the timing. Some music replays sometimes do strange things : write several times in the same register, don't use some registers at all, use a 200 Hz replay freq, ...
Another method could be to dump the YM resisters at the same rate (or fraction) as the .WAV file.

Do you mean dumping all 14 regs at 44.1 kHz for example ? That would make a huge buffer in memory.
And then, how do you remove consecutive bytes to choose the 14 bytes that represent this VBL ? It can be complicated, because replay don't change all registers in one go, so you won't see a whole transition of all registers, but a progressive one. It can be hard to choose the 14 registers. Also if you consider that some replays sometimes need several HBL between writing in each register.

I spent a lot of time adapting ST replay for my YM2149 emulator on Amiga and I came across a lot of different scenario. If you wait for all 14 regs to be updated on each VBL, this will never happen, some replays don't use all registers. I think the register supposed to be updated the most is reg 7, with on/off bits for voice/noise, but even so, some replays set reg7 only at start and never change it later, so you can't monitor reg7 to detect a new YM record.

All in all, I don't see any easy method to guess the 14 registers need to updated in the YM file. There might be more complicated method, but if we consider that 99% of demos/games are playing music during the VBL, I'm not sure it's worth the effort.

For FedePede04 :
Regarding David Whittaker musics, IIRC they read $ff820A and will adapt the replay speed to have a correct tempo when playing at 60Hz or 50 Hz.
As for music using a much higher replay, this is a limitation of the StSound format anyway : the format doesn't include the original recording freq, it just assumes music will be played on each VBL. So even if you record a music with a 200 Hz replay freq, it will sound wrong (too slow) because StSound player will play it only once per VBL.

Nicolas

Hippy Dave
Atari Super Hero
Atari Super Hero
Posts: 515
Joined: Sat Jan 10, 2009 5:40 am

Re: YM recording unstable

Postby Hippy Dave » Sun May 25, 2014 9:40 pm

Another idea... Make a new YM file specification:

- 4 Bytes for file identifier (magic)
- 2 Bytes for file Header size (Header can be zero length).
- Header Bytes {
song titles, copyright, whatever
}
- 4 Bytes time since last sample in microseconds
- 1 Byte for YM register number
- 1 Byte for YM register data
...
- 4 Bytes time since last sample in microseconds
- 1 Byte for YM register number
- 1 Byte for YM register data

(note that the last sample is not played because it has no end time... the last sample must be a dummy)

in Hatari, the Sound_WriteReg( int reg , Uint8 data ) function could produce the data.
Last edited by Hippy Dave on Sun May 25, 2014 9:52 pm, edited 1 time in total.

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: YM recording unstable

Postby FedePede04 » Sun May 25, 2014 9:42 pm

npomarede wrote:Regarding David Whittaker musics, IIRC they read $ff820A and will adapt the replay speed to have a correct tempo when playing at 60Hz or 50 Hz.
As for music using a much higher replay, this is a limitation of the StSound format anyway : the format doesn't include the original recording freq, it just assumes music will be played on each VBL. So even if you record a music with a 200 Hz replay freq, it will sound wrong (too slow) because StSound player will play it only once per VBL.

Nicolas


hi Nicolas
i don't know how they did it, i have not check out the code, but i just know that they play it in 60hz regardless if the computer is in PAL, i was thinking that they use a timer for it.
but it was more a though that if the score was playing at 60hz and you capture it a 50hz, then you will not get the data change on the exact time. but i don't know if it matters in any way :)

actually the YM5 and YM6 support different play speed (word at offset 26) but i don't think that any YM player support it.
a new version of my ym2149 player do support it, but it not finish yet, it should have been finish for some time ago, but i have been sick for the last couple of month. but i hope that i soon can continue my work on it :)
for me it could be really great, if you support export ym in different speed, but i also fully understand, that if it never happen. :)

/Peter
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Mon May 26, 2014 9:40 am

Hippy Dave wrote:Another idea... Make a new YM file specification:
...
in Hatari, the Sound_WriteReg( int reg , Uint8 data ) function could produce the data.


This could be done, but I'm not sure it would be widely used.
At the start, purpose of the YM format (or other variants) was to free as many cpu cycles as possible by just recording the sound registers on each vbl (you play the original music in "max speed" mode and store all the 14 registers after each call). You get a big buffer of data, but a very fast replay where you just need to copy 14 regs, no other computations to do. Having a fixed number of register per VBL is also useful if you want to seek very fast at a precise point.

Storing all register writes with the absolute cpu time of the write would allow to store all data, but the player would be slightly more complicated.

It's an intermediate solution, but I'm not sure it has many uses : a normal player will usually take ~10 HBL lines or less, an YM player would take less than 1 HBL line.
Storing all the writes with their time would need more cpu to play the data (maybe 3-4 HBL lines) and furthermore, there's no 68000 player for that format, so I doubt it would be used in many programs. So, quite some work for little use I'm afraid.

The fact that YM3 format is tied to a VBL frequency doesn't seem such a problem to me, nearly all games/demos play music during the VBL.
It even looks like an error to me that Maxymiser uses a timer to play the music when most of the time music were used in demo and played with a slightly different freq of one VBL (but it's not really hearable). It would be better that mxymiser plays song in the same way that it will be played in demos.


Nicolas

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Mon May 26, 2014 10:02 am

FedePede04 wrote:hi Nicolas
i don't know how they did it, i have not check out the code, but i just know that they play it in 60hz regardless if the computer is in PAL, i was thinking that they use a timer for it.
but it was more a though that if the score was playing at 60hz and you capture it a 50hz, then you will not get the data change on the exact time. but i don't know if it matters in any way :)

That's the opposite in fact : music is supposed to play at 50 Hz, but the replay will slow down by not playing data every 6th VBL in 60 Hz.
See this code from "Return To Genesis" :

Code: Select all

$013168 : 4e75                                 rts       
$01316a : 47fa fef8                            lea       $13064(pc),a3
$01316e : 0839 0001 00ff 820a                  btst      #1,$ff820a
$013176 : 660e                                 bne.s     $13186
$013178 : 532b 0103                            subq.b    #1,$103(a3)
$01317c : 6608                                 bne.s     $13186
$01317e : 177c 0006 0103                       move.b    #6,$103(a3)
$013184 : 60e2                                 bra.s     $13168

This is how the music sounds the same with a PAL TOS or a NTSC TOS.
actually the YM5 and YM6 support different play speed (word at offset 26) but i don't think that any YM player support it.
a new version of my ym2149 player do support it, but it not finish yet, it should have been finish for some time ago, but i have been sick for the last couple of month. but i hope that i soon can continue my work on it :)
for me it could be really great, if you support export ym in different speed, but i also fully understand, that if it never happen. :)
/Peter

YM5 and YM6 are much more complex, they allow to store digidrums, timer based effects (sid voices) and also have an additional lzh compression above. But it's even harder to record a music and automatically store the parameters for the digidrum / timers, all songs stored this way where certainly hand edited by studying each music replay.
So, I don't think it would make much sense to add this to Hatari.

Nicolas

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: YM recording unstable

Postby FedePede04 » Mon May 26, 2014 1:44 pm

Hi Nicolas
i do not doubt what you are saying, i know that you are very much into the sound on the atari st.
but i could have sworn, that the music of Archipelago is running at 60hz, than i check it out, i even made a new YM dump using Hatari to make sure that my ym dump was correct, and i have to play it in 60hz, before it sounded the same as it does in the game. i also had a feling the gold runner 2 was running at 60hz, but i have not check it out, so that is only a guess.

you are right about the ym5/ym6 regarding sid/digi and ect sound, it is nearly impossible to make them using an auto recorder, you need to hand make them, but there are nothing wrong in using the YM5 header for pure YM sound, and one could always lzh the files afterwards.

but i know that not many want this feature, and i also know that you don't have much time, so you have to priority what is important to add to Hatari, so i am perfectly fine with that it never will be add :(


:)
but i will still dream of YM file format with variable speed :D

/Peter



npomarede wrote:
FedePede04 wrote:hi Nicolas
i don't know how they did it, i have not check out the code, but i just know that they play it in 60hz regardless if the computer is in PAL, i was thinking that they use a timer for it.
but it was more a though that if the score was playing at 60hz and you capture it a 50hz, then you will not get the data change on the exact time. but i don't know if it matters in any way :)

That's the opposite in fact : music is supposed to play at 50 Hz, but the replay will slow down by not playing data every 6th VBL in 60 Hz.
See this code from "Return To Genesis" :

Code: Select all

$013168 : 4e75                                 rts       
$01316a : 47fa fef8                            lea       $13064(pc),a3
$01316e : 0839 0001 00ff 820a                  btst      #1,$ff820a
$013176 : 660e                                 bne.s     $13186
$013178 : 532b 0103                            subq.b    #1,$103(a3)
$01317c : 6608                                 bne.s     $13186
$01317e : 177c 0006 0103                       move.b    #6,$103(a3)
$013184 : 60e2                                 bra.s     $13168

This is how the music sounds the same with a PAL TOS or a NTSC TOS.
actually the YM5 and YM6 support different play speed (word at offset 26) but i don't think that any YM player support it.
a new version of my ym2149 player do support it, but it not finish yet, it should have been finish for some time ago, but i have been sick for the last couple of month. but i hope that i soon can continue my work on it :)
for me it could be really great, if you support export ym in different speed, but i also fully understand, that if it never happen. :)
/Peter

YM5 and YM6 are much more complex, they allow to store digidrums, timer based effects (sid voices) and also have an additional lzh compression above. But it's even harder to record a music and automatically store the parameters for the digidrum / timers, all songs stored this way where certainly hand edited by studying each music replay.
So, I don't think it would make much sense to add this to Hatari.

Nicolas
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
npomarede
Atari God
Atari God
Posts: 1311
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: YM recording unstable

Postby npomarede » Mon May 26, 2014 2:14 pm

FedePede04 wrote:Hi Nicolas
i do not doubt what you are saying, i know that you are very much into the sound on the atari st.
but i could have sworn, that the music of Archipelago is running at 60hz, than i check it out, i even made a new YM dump using Hatari to make sure that my ym dump was correct, and i have to play it in 60hz, before it sounded the same as it does in the game. i also had a feling the gold runner 2 was running at 60hz, but i have not check it out, so that is only a guess.

Maybe Archipelagos was specifically designed to run only at 60 Hz and the music was made to match 60 Hz too, but I would say this is an exception, I'm pretty sure all David Whittaker musics are supposed to run at 50 Hz (see the V8 Music disk for examples of many songs, the demo is running at 50 Hz)

EDIT : note that if you started Archipelagos with a NTSC TOS, it will run at 60 Hz and the replay will run at 60 Hz, so you need a 60 Hz replay for the YM3 file. But if you start with a PAL TOS (french one for example), I think replay will be at 50 Hz and you can play the YM3 file at 50 Hz (this is what I saw in Return To Genesis)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: YM recording unstable

Postby FedePede04 » Mon May 26, 2014 5:38 pm

Hi Nicolas

npomarede wrote:note that if you started Archipelagos with a NTSC TOS, it will run at 60 Hz and the replay will run at 60 Hz, so you need a 60 Hz replay for the YM3 file. But if you start with a PAL TOS (french one for example), I think replay will be at 50 Hz and you can play the YM3 file at 50 Hz (this is what I saw in Return To Genesis)


I just retested Archipelagos and it look like that i was recording the file with an NTSC TOS, i was sure that it was an UK tos that i used. that original YM file of Archipelagos that i had (not capture my self) was also capture in 60HZ. so i was pretty sure in my case.

sorry for taking up your time :oops:
/peter
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 3 guests