Yamaha RX-5 ROM format parser/extractor

Discussions about anything related to samplers and sampling techniques.

Yamaha RX-5 ROM format parser/extractor

Postby ʝɵʝɵ » Fri Mar 10, 2017 12:53 am

Back in 2010, a friend was going to circuit-bend a Yamaha RX-5 for me, including the possibility to replace the samples ROM. Sadly this project was never finished, I still don't have an RX-5 but I just found this old piece of FreeBASIC code from back then (I was just transitioning to mainly programming in C++ at that time) which parses the sample headers, prints out some debug info and dumps the sample data. Some stuff remains unknown since I did not know the exact parameters used on the device back then. But hey, maybe someone will find this code snippet to be helpful someday.

Code: Select all
' RX-5 ROM extractor
' By Saga Games
' https://sagagames.de/
' BSD license

#Define ROM_FILE "M5M23C100-512P.bin"
'#Define ROM_FILE "M5M23C100-513P-4.bin"
#Define DUMP_SAMPLES

#Include "vbcompat.bi"

#Macro BSWAP32(a)
Asm
   mov eax, [a]
   bswap eax
   mov [a], eax
End Asm
#EndMacro

#Define BSWAP16(a) a = (((a And &HFF) Shl 8) Or ((a And &HFF00) Shr 8))

Function Checksum(Bytes As Byte Ptr, BLen As Integer) As Integer
   Dim As UShort chsum = 0, origsum = 0
   For i As Integer = 0 To BLen - 3
      chsum += *Cast(UByte Ptr, @Bytes[i])
   Next
   origsum = *Cast(UShort Ptr, @Bytes[BLen - 2])
   BSWAP16(origsum)
   If(origsum = chsum) Then Return chsum Else Return -1
End Function

Type filehead Field = 1
   Dim As UInteger nulls
   Dim As UByte unknown
   Dim As UByte numsamples
End Type

Type smphead Field = 1
   Dim As UShort unknown1   ' $02, $78
   Dim As UByte flags      ' 01 = 12-bit, 00 = 8-bit
   Dim As UByte unknown2   ' AND 01 is loop on??? what is AND $40?
   Dim As UShort offset
   Dim As UShort unknown3
   Dim As UInteger endoffset
   Dim As UShort loopend
   Dim As ZString * 12 unknown4
   Dim As ZString * 6 sname
End Type

Assert(SizeOf(smphead) = 32)

Open ROM_FILE For Binary As #1

Dim As filehead  fhead
Get #1, 1, fhead

Dim As smphead sheader
Dim As UInteger fulloffset, fulllength, loopend

Print fhead.numsamples & " samples..."
Print

For i As Integer = 1 To fhead.numsamples
   Get #1, , sheader

   fulloffset = (sheader.offset And &H0FFF) Shl 8 ' the low 8 bits of the offset are not stored (this allows 24-bit addressing)

   fulllength = sheader.endoffset
   BSWAP32(fulllength)
   fulllength = ((fulllength And &H0FFFFF00) Shr 8) - fulloffset

   loopend = sheader.loopend
   BSWAP16(loopend)
   loopend = (loopend And &H0FFFFF) - fulloffset

   Print Hex(i, 2) & " " & sheader.sname; ": Offset $" & Hex(fulloffset, 5) & " - Length $" & Hex(fulllength, 5) & " - LEnd $" & Hex(loopend, 5) & " - ";
   If(sheader.flags And &H01) Then Print "12-bit" Else Print "8-bit"
   If(sheader.flags > 1) Then Print "UNKNOWN FLAG ERROR!"

   ' dumping samples
   #Ifdef DUMP_SAMPLES
   Dim As Integer oldpos = Loc(1)
   Kill Trim(sheader.sname)
   Open Trim(sheader.sname) For Binary As #2
   Dim As String buffer = Space(fulllength)
   Get #1, fulloffset + 1,buffer
   Put #2, 1,buffer
   Close #2
   Seek #1, oldpos + 1
   #EndIf
Next

Print

Dim As Integer romChSum
Dim As Byte Ptr romData = Allocate(Lof(1))
Get #1, 1, *romData, Lof(1)

#Macro CalcChecksum(sName, nLen)
romChSum = Checksum(romData, nLen)
If(romChSum <> - 1) Then Print sName & " checksum OK (" & Hex(romChSum) & ")" Else Print sName & " checksum error!"
#EndMacro

CalcChecksum("Header", 1024)
CalcChecksum("ROM", Lof(1))

Close #1

Sleep


Note: Not tested on recent FreeBASIC compiler. They have removed a lot of old cruft from the main language dialect (which is good!) so I don't know if it still compiles.
ʝɵʝɵ
Newbie
Newbie
 
Posts: 86
Joined: Sat Jun 11, 2011 11:50 am
Location: Germany
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, Korg X5DR, Kawai K4

Re: Yamaha RX-5 ROM format parser/extractor

Postby madtheory » Fri Mar 10, 2017 11:12 am

That's pretty cool! If someone could go ahead and just extract the samples to WAVs, I'd be happy :) It's fascinating to play back samples from ancient machines with modern hardware. IMO the greater part of the character comes from the sampling/ encoding process, not the playback, as long as there is no transposing in playback of course.
User avatar
madtheory
Supporting Member!
Supporting Member!
 
Posts: 4835
Joined: Mon May 01, 2006 12:45 pm
Location: Cork, Ireland
Real name: Tomas Mulcahy
Gear: Novation KSR, PT12, VCZ, Redmatica, MIDIQuest, Casio FZ, SK5, Komplete, M1, Theremin, Digi Vocalist, Quadravrb+, Kaoss Pad, JV, SPD, Cyclone, Drummer.
Band: madtheory

Re: Yamaha RX-5 ROM format parser/extractor

Postby ʝɵʝɵ » Fri Mar 10, 2017 12:53 pm

madtheory wrote:That's pretty cool! If someone could go ahead and just extract the samples to WAVs, I'd be happy :)

I can do that later. I do still have the two ROM files, M5M23C100-512P.bin and M5M23C100-513P-4.bin, but I don't remember exactly where those came from, and in particular if the RX-5 used two ROMs or if one of them was an expansion, etc.
ʝɵʝɵ
Newbie
Newbie
 
Posts: 86
Joined: Sat Jun 11, 2011 11:50 am
Location: Germany
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, Korg X5DR, Kawai K4

Re: Yamaha RX-5 ROM format parser/extractor

Postby ʝɵʝɵ » Mon Mar 13, 2017 9:46 pm

Waveform data (8bit / 16bit)

The layout of the 12-bit sample data is as follows:
Read three bytes and split them into nibbles: B0Low, B0High, B1Low, B1High, B2Low, B2High
This gives us two 16-bit samples:
Sample1 = (B1High << 12) | (B1Low << 8) | (B2High << 4)
Sample2 = (B2Low << 12) | (B3High << 8) | (B3Low << 4)
ʝɵʝɵ
Newbie
Newbie
 
Posts: 86
Joined: Sat Jun 11, 2011 11:50 am
Location: Germany
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, Korg X5DR, Kawai K4

Re: Yamaha RX-5 ROM format parser/extractor

Postby madtheory » Sun Mar 19, 2017 2:22 pm

O cool. These sound a bit different to what I remember on the machine though. Is there compansion?
User avatar
madtheory
Supporting Member!
Supporting Member!
 
Posts: 4835
Joined: Mon May 01, 2006 12:45 pm
Location: Cork, Ireland
Real name: Tomas Mulcahy
Gear: Novation KSR, PT12, VCZ, Redmatica, MIDIQuest, Casio FZ, SK5, Komplete, M1, Theremin, Digi Vocalist, Quadravrb+, Kaoss Pad, JV, SPD, Cyclone, Drummer.
Band: madtheory

Re: Yamaha RX-5 ROM format parser/extractor

Postby ʝɵʝɵ » Sun Mar 19, 2017 2:29 pm

madtheory wrote:O cool. These sound a bit different to what I remember on the machine though. Is there compansion?

I would guess that the samples are compressed and there are volume envelopes to shape the sound, simply to have the best possible SNR on the stored samples. I didn't fully reverse-engineer the ROM format, so I don't know the details.
ʝɵʝɵ
Newbie
Newbie
 
Posts: 86
Joined: Sat Jun 11, 2011 11:50 am
Location: Germany
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, Korg X5DR, Kawai K4

Re: Yamaha RX-5 ROM format parser/extractor

Postby gmeredith » Mon Mar 20, 2017 12:56 am

The actual raw samples, especially of those 80s era sampled machines, sound very different from the sound that comes out of the analog outputs. People have extracted the TR707 wav files and found them to be almost unrecognisable. 4-bit samples compressed to within an inch of their lives! The companding and VCA circuitry did all the work, so that tiny amounts of RAM could be used and still have good S/N ratios and sample times, which was expensive back then.

It's much better to sample the actual outputs of the machines, if you want to use the samples in modern, equipment, that's what I do. The sound of the machine is much more than just its samples, it's the whole package that gives the characteristic sound. Do a search, especially on Freesound, there are lots of instrument sounds from drum machines already sampled there for you to load
Casio: FZ1, CZ101, PG380, VZ10M, SK8, SK60, RAP10, DP1 drums, DH100, CDP200, DM100
Yamaha: TX81z, TX802, SHS10, DTXv2
Roland: SH101, DR660, MS1, PM16, TR33
Others: Korg MicroKontrol, ES-1, Alesis MMT8, Emu ESi2000 & card reader, BCR2000, V-Machine
User avatar
gmeredith
Moderator
Moderator
 
Posts: 680
Joined: Mon Oct 17, 2005 5:06 am
Location: Tasmania, Australia
Band: Warning Will Robinson

Re: Yamaha RX-5 ROM format parser/extractor

Postby ʝɵʝɵ » Mon Mar 20, 2017 11:22 am

It's also worth noting that the awesome kb6 drum collection has RX-5 samples.

It's much better to sample the actual outputs of the machines, if you want to use the samples in modern, equipment, that's what I do. The sound of the machine is much more than just its samples, it's the whole package that gives the characteristic sound.

In principal I do agree, but sometimes you want to do things with the original waveforms that are not possible with the original machine. :) In that case, applying a volume envelope to the ripped samples and then processing them further might be the best solution.
ʝɵʝɵ
Newbie
Newbie
 
Posts: 86
Joined: Sat Jun 11, 2011 11:50 am
Location: Germany
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, Korg X5DR, Kawai K4

Re: Yamaha RX-5 ROM format parser/extractor

Postby madtheory » Mon Mar 20, 2017 1:48 pm

Agreed. It's not necessarily better to have the ROMs or the DAC output. False dichotomy. Both have wide sonic possibilities. This case here of the ROMs is pretty cool, because that's not been available before AFAIK. There's a ton of samples of RX-5 DAC outputs out there. It's also interesting to discover which machines companded and which did not.

So did Yamaha use some kind of fairly simple companding? I guess a file comparison of DAC out vs ROM would reveal the envelope used?
User avatar
madtheory
Supporting Member!
Supporting Member!
 
Posts: 4835
Joined: Mon May 01, 2006 12:45 pm
Location: Cork, Ireland
Real name: Tomas Mulcahy
Gear: Novation KSR, PT12, VCZ, Redmatica, MIDIQuest, Casio FZ, SK5, Komplete, M1, Theremin, Digi Vocalist, Quadravrb+, Kaoss Pad, JV, SPD, Cyclone, Drummer.
Band: madtheory


Return to Samplers

Who is online

Users browsing this forum: No registered users and 1 guest