quote=cyberic Hello garvalf, could you please share the converter script? it's great! Thx/quote

sure.

It's not very clean or use-friendly at the moment, but here is what I did:

First, find some vopm instruments (or design them yourself with the vst plugin, but it's probably easier to use the Ctrlr tool made by synthy if it's for this purpose).

The cool thing is you can find some 1300 instruments (or games) packed from this link: urlhttps://www.youtube.com/watch?v=EKQDpWZWIDU/url (which link to there: urlhttp://www.mediafire.com/download.php?od9s1zgbk4ig125)/url

The vopm will export to something like that:


LFO: 0 0 0 0 0
CH: 64 7 2 0 0 120 0
M1: 31 6 0 1 1 33 2 0 3 0 0
C1: 28 5 0 5 5 37 2 3 3 0 0
M2: 27 31 0 3 0 31 1 0 3 0 0
C2: 13 3 0 6 0 25 1 0 3 0 0

copy it to a vopm.txt file.

Then you can use this vopm2arduino script:


cat vopm.txt |\
perl -pe 's|LFO:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|LFRQ= ;\n\/\/AMS = ;\n\/\/PMS = ;\nLWav = ;\nNFRQ = ;\n|' | \
perl -pe 's|CH:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|PA= ;\nFB = ;\nCON = ;\nAMS = ;\nPMS = ;\nLMod = ;\nNoise = ;\n|' |\
perl -pe 's|M1:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|AR0= ;\nD1R0 = ;\nD2R0 = ;\nRR0 = ;\nD1L0 = ;\nTL0 = ;\nKS0 = ;\nMUL0 = ;\nDT10 = ;\nDT20 = 000;\n\/\/AMS-EN = \g11;\n|' |\
perl -pe 's|C1:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|AR1= ;\nD1R1 = ;\nD2R1 = ;\nRR1 = ;\nD1L1 = ;\nTL1 = ;\nKS1 = ;\nMUL1 = ;\nDT11 = ;\nDT21 = 000;\n\/\/AMS-EN = \g11;\n|' |\
perl -pe 's|M2:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|AR2= ;\nD1R2 = ;\nD2R2 = ;\nRR2 = ;\nD1L2 = ;\nTL2 = ;\nKS2 = ;\nMUL2 = ;\nDT12 = ;\nDT22 = 000;\n\/\/AMS-EN = \g11;\n|' |\
perl -pe 's|C2:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|AR3= ;\nD1R3 = ;\nD2R3 = ;\nRR3 = ;\nD1L3 = ;\nTL3 = ;\nKS3 = ;\nMUL3 = ;\nDT13 = ;\nDT23 = 000;\n\/\/AMS-EN = \g11;\n|' 

remplace 000 by \g10 with perl 22 (Edit)

in my current pearl implementation, \g10 is not supported, but this DT2 is not much used so it's not a problem.

The script will output to the terminal, which you can redirect to a file. Then copy/paste this output to a DefaultInstrument.h file you can put into your arduino project (midi_in_ym2151). Call this file from the part after:


   sysexValue5 = 59;
   sysexValue6 = 15-RR3;
   MIDI.sendSysEx(8,sysexValue, true);

and before code YM2151.write(0x0f,(Noise<<8) + NRFQ);/code

When you compile the arduino sketch, it will make the instrument defined in the vopm.txt file as default. You can still alter this with the ctrlr panel. The problem is it's quite tedious to change from one instrument to an other (you have to compile the sketch). You also cannot output from the perl script to the DefaultInstrument.h file, because the arduino IDE doesn't reload if you modify the file externally. You can problably compile it with avrdude directly.

i've tried a few instruments from famous games, and compare them with the original songs, and they sound very close, so it's quite great. It would be even cooler if it could change the values into to ctrlr panels

So I've thought it would be better to use SysEx to change the values on the fly (it's what Ctrlr does by the way).

I made another script, for converting to SysEx:


cat vopm.txt | \
perl -pe 's|LFO:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|\
 printf("F0 00 00 00 00 08 ") ; printf("%x ",$1*2) ; printf("F7 "); printf("F0 00 00 00 00 07 ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 06 ") ; printf("%x ",$6) ; printf("F7 ");  |e' | \
perl -pe 's|CH:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*| printf("F0 00 00 00 00 09 ") ; printf("%x ",$1) ; printf("F7 "); printf("F0 00 00 00 00 01 ") ; printf("%x ",$2) ; printf("F7 "); printf("F0 00 00 00 00 0B ") ; printf("%x ",$3) ; printf("F7 "); printf("F0 00 00 00 00 04 ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 05 ") ; printf("%x ",$5) ; printf("F7 "); printf("F0 00 00 00 00 0A ") ; printf("%x ",$6) ; printf("F7 "); printf("F0 00 00 00 00 03 ") ; printf("%x ",$7) ; printf("F7 "); |e' |\
perl -pe 's|M1:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|printf("F0 00 00 00 00 18 ") ; printf("%x ",$1) ; printf("F7 "); printf("F0 00 00 00 00 19 ") ; printf("%x ",$2) ; printf("F7 "); printf("F0 00 00 00 00 1B ") ; printf("%x ",$3) ; printf("F7 "); printf("F0 00 00 00 00 1D ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 1C ") ; printf("%x ",$5) ; printf("F7 "); printf("F0 00 00 00 00 16 ") ; printf("%x ",$6) ; printf("F7 "); printf("F0 00 00 00 00 17 ") ; printf("%x ",$7) ; printf("F7 "); printf("F0 00 00 00 00 15 ") ; printf("%x ",$8) ; printf("F7 "); printf("F0 00 00 00 00 14 ") ; printf("%x ",$9) ; printf("F7 "); printf("F0 00 00 00 00 1A ") ; printf("%x ",00) ; printf("F7 "); |e' |\
perl -pe 's|C1:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|printf("F0 00 00 00 00 22 ") ; printf("%x ",$1) ; printf("F7 "); printf("F0 00 00 00 00 23 ") ; printf("%x ",$2) ; printf("F7 "); printf("F0 00 00 00 00 25 ") ; printf("%x ",$3) ; printf("F7 "); printf("F0 00 00 00 00 27 ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 26 ") ; printf("%x ",$5) ; printf("F7 "); printf("F0 00 00 00 00 20 ") ; printf("%x ",$6) ; printf("F7 "); printf("F0 00 00 00 00 21 ") ; printf("%x ",$7) ; printf("F7 "); printf("F0 00 00 00 00 1F ") ; printf("%x ",$8) ; printf("F7 "); printf("F0 00 00 00 00 1E ") ; printf("%x ",$9) ; printf("F7 "); printf("F0 00 00 00 00 24 ") ; printf("%x ",00) ; printf("F7 "); |e' |\
perl -pe 's|M2:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|printf("F0 00 00 00 00 2C ") ; printf("%x ",$1) ; printf("F7 "); printf("F0 00 00 00 00 2D ") ; printf("%x ",$2) ; printf("F7 "); printf("F0 00 00 00 00 2F ") ; printf("%x ",$3) ; printf("F7 "); printf("F0 00 00 00 00 31 ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 30 ") ; printf("%x ",$5) ; printf("F7 "); printf("F0 00 00 00 00 2A ") ; printf("%x ",$6) ; printf("F7 "); printf("F0 00 00 00 00 2B ") ; printf("%x ",$7) ; printf("F7 "); printf("F0 00 00 00 00 29 ") ; printf("%x ",$8) ; printf("F7 "); printf("F0 00 00 00 00 28 ") ; printf("%x ",$9) ; printf("F7 "); printf("F0 00 00 00 00 2E ") ; printf("%x ",00) ; printf("F7 "); |e' |\
perl -pe 's|C2:\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*|printf("F0 00 00 00 00 36 ") ; printf("%x ",$1) ; printf("F7 "); printf("F0 00 00 00 00 37 ") ; printf("%x ",$2) ; printf("F7 "); printf("F0 00 00 00 00 39 ") ; printf("%x ",$3) ; printf("F7 "); printf("F0 00 00 00 00 3B ") ; printf("%x ",$4) ; printf("F7 "); printf("F0 00 00 00 00 3A ") ; printf("%x ",$5) ; printf("F7 "); printf("F0 00 00 00 00 34 ") ; printf("%x ",$6) ; printf("F7 "); printf("F0 00 00 00 00 35 ") ; printf("%x ",$7) ; printf("F7 "); printf("F0 00 00 00 00 33 ") ; printf("%x ",$8) ; printf("F7 "); printf("F0 00 00 00 00 32 ") ; printf("%x ",$9) ; printf("F7 "); printf("F0 00 00 00 00 38 ") ; printf("%x ",00) ; printf("F7 "); |e' | perl -pe 's|\s(\d{1}?)\s| 0$1 |g' | perl -pe 's|\s(abcdef)\s| 0$1 |g'  

remplace 00 in printf("%x ",00) by $10 with perl 22 (Edit)

(Edit)

Again, it output to the console, whic you can redirect to a sysex.txt file. And you can send the sysex to the shield by using the amidi command line:

amidi -p hw:0 -S 'F0 00 00 00 00 0B 05 F7 F0 00 00 00 00 16 00 F7 etc.'

Then, after we send the values, the shield remains silent. We can get the sound if we reset the arduino. But then, the sound is not very accurate. I hadn't tested enough but I think it doesn't work, or it sends partial data. Maybe i made a mistake in the values in the script, or it's too much data at the same time...

I've made a last script, which convert the whole bunch of data from the systex.txt file to a one operation at a time:


cat sysex.txt | perl -pe 's|\s(\d{1}?)\s| 0$1 |g' | perl -pe 's|\s(abcdef)\s| 0$1 |g' | \
perl -pe "s/F0(.*?)F7/amidi -p hw:0 -S 'F0F7'\n/g"

so we get something like that at the end:


amidi -p hw:0 -S 'F0 00 00 00 00 36 0d F7'
amidi -p hw:0 -S 'F0 00 00 00 00 37 03 F7'
amidi -p hw:0 -S 'F0 00 00 00 00 39 00 F7'
amidi -p hw:0 -S 'F0 00 00 00 00 3B 06 F7'

but it's not better...

Powered by LionWiki-t2t
  Edit   History