Yamaha RX-5 ROM format parser/extractor

Discussions about anything related to samplers and sampling techniques.
ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » 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.

User avatar
madtheory
Supporting Member!
Supporting Member!
Posts: 5147
Joined: Mon May 01, 2006 12:45 pm
Real name: Tomas Mulcahy
Gear: Flangebeast Mk1, Plonkotron, Morovdis Arpeggiator, Maplin My First EQ, Jeff Wayne Thunderchild rack, Thermostat, Buck Owens' Moog.
Band: Minim
Location: Cork, Ireland
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by 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.

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » 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.

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » 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)

User avatar
madtheory
Supporting Member!
Supporting Member!
Posts: 5147
Joined: Mon May 01, 2006 12:45 pm
Real name: Tomas Mulcahy
Gear: Flangebeast Mk1, Plonkotron, Morovdis Arpeggiator, Maplin My First EQ, Jeff Wayne Thunderchild rack, Thermostat, Buck Owens' Moog.
Band: Minim
Location: Cork, Ireland
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by 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?

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » 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.

User avatar
gmeredith
Moderator
Moderator
Posts: 706
Joined: Mon Oct 17, 2005 5:06 am
Band: Warning Will Robinson
Location: Tasmania, Australia
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by 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

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » 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.

User avatar
madtheory
Supporting Member!
Supporting Member!
Posts: 5147
Joined: Mon May 01, 2006 12:45 pm
Real name: Tomas Mulcahy
Gear: Flangebeast Mk1, Plonkotron, Morovdis Arpeggiator, Maplin My First EQ, Jeff Wayne Thunderchild rack, Thermostat, Buck Owens' Moog.
Band: Minim
Location: Cork, Ireland
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by 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?

Anders Schroder
Newbie
Newbie
Posts: 1
Joined: Fri Nov 23, 2018 11:26 am

Re: Yamaha RX-5 ROM format parser/extractor

Post by Anders Schroder » Fri Nov 23, 2018 11:29 am

I have all the ROMS. can someone help me with dumping them to wavs?

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » Sun Nov 25, 2018 10:28 pm

Hello Anders,
I have compiled the program from my first post of this topic into a Windows EXE file. You can download it here:
https://sagagames.de/stuff/rx5extract.zip
Drop a ROM file on the executable and it should extract the WAV files in the same folder as the EXE file.
This was only tested on the stock ROM so I cannot guarantee that it works with other ROMs.
Hope this helps.

User avatar
madtheory
Supporting Member!
Supporting Member!
Posts: 5147
Joined: Mon May 01, 2006 12:45 pm
Real name: Tomas Mulcahy
Gear: Flangebeast Mk1, Plonkotron, Morovdis Arpeggiator, Maplin My First EQ, Jeff Wayne Thunderchild rack, Thermostat, Buck Owens' Moog.
Band: Minim
Location: Cork, Ireland
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by madtheory » Mon Nov 26, 2018 9:36 pm

Do you think you could do the same for the Alesis SR-16? The raw ROM is an interleaved format stored as 8 bit data IIRC. Doesn't seem to be companded. Could do it manually, but it's a lot of editing, with the velocity layers.

Problem is burnkit site, where it was uploaded, is currently down :(

ʝɵʝɵ
Junior Member
Junior Member
Posts: 139
Joined: Sat Jun 11, 2011 11:50 am
Gear: Roland D-50, U-220, XV-5080, Yamaha AN1x, CS1x, CS6R, TG77, Korg X5DR, Kawai K4, Kurzweil K2500
Location: Germany
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by ʝɵʝɵ » Mon Nov 26, 2018 9:56 pm

Truth is, I am already swamped in project so I'd rather spend the time I would have to invest into this into more urgent things.

User avatar
madtheory
Supporting Member!
Supporting Member!
Posts: 5147
Joined: Mon May 01, 2006 12:45 pm
Real name: Tomas Mulcahy
Gear: Flangebeast Mk1, Plonkotron, Morovdis Arpeggiator, Maplin My First EQ, Jeff Wayne Thunderchild rack, Thermostat, Buck Owens' Moog.
Band: Minim
Location: Cork, Ireland
Contact:

Re: Yamaha RX-5 ROM format parser/extractor

Post by madtheory » Tue Nov 27, 2018 8:42 am

That's cool, thanks again for doing this RX-5 one! PS your awesome MRAM card is still going strong in this studio :)

Rasputin
Active Member
Active Member
Posts: 722
Joined: Thu Jul 21, 2016 4:52 am

Re: Yamaha RX-5 ROM format parser/extractor

Post by Rasputin » Wed Nov 28, 2018 3:07 pm

madtheory wrote:Do you think you could do the same for the Alesis SR-16? The raw ROM is an interleaved format stored as 8 bit data IIRC. Doesn't seem to be companded. Could do it manually, but it's a lot of editing, with the velocity layers.

Problem is burnkit site, where it was uploaded, is currently down :(
If you need an Alesis SR16 sound ROM extractor tool, I could probably make one for you in a day or two.

Post Reply