Discussion:
Strange TG77 checksum error
(too old to reply)
Alan
2010-01-10 06:59:54 UTC
Permalink
I have noticed a strange quirk of the the SY77/TG77. This module has 64 voices in the user-customizable memory. These 64 voices are subdivided into four banks of 16 voices each. When a voice that is in Bank D, that is, a voice that is numbered 49 to 64, is moved to a lower number, the TG77 always generates a checksum error when it receives the sysex data from the PC. But any voice in
the other three banks can be moved to any other location without the TG77 giving an error. A voice that originally numbered 49-64 can be renumbered in the 49-64 range and loaded into the TG77 without a checksum error. But any voice 49-64 can't be changed to, say, voice 9 and be reloaded without a giving checksum error. Voice 9 can be changed to voice 64 and reloaded without problem.

The checksum itself is correct in all the instances. I wrote a small Visual Basic program to open a sysex file of the voice data and calculate the checksum when the voice location is adjusted. I always get the original checksum when the new voice location is the same as the original location, so the calculation code is correct (7-bit twos-complement of the sum of the bytes between offset #6 and the EOX 0xF7).

The voice's location is fixed in the voice sysex data at offset 0x1f (starting at offset 0, which is 0xF0). Adjusting this byte changes the location of the voice in the I-bank. The checksum has to be recalculated because the voice's location in the User memory (the I-bank) is part of the voice data.

Doing this allows the making of custom banks from the 14000 voices
that can be found on the web. Most of the voices in each of these banks are uninteresting. But each bank is in a single sysex file that fills the entire TG77 user-memory area when sent from the PC.
So you get the whole I-bank filled and only one or two good voices per file.

The way to get around this is to separate each of the 64 voices into a separate sysex file that starts with 0xf0 and ends with 0xf7. Then change the I-bank location for the good voices and send each voice to the TG77 individually. Then have the TG77 send the entire bank's data to the PC, which stores as a single new bank file.

Each voice file has a different length depending on the type of TG77 voice that it is: 1AFM, 2AWM, Drum, etc... But this doesn't tactic doesn't work if the voice is originally numbered 49-64.

There has to be some undocumented place in the sysex data that indicates that the original voice was from location 49-64. Otherwise there couldn't be this fake checksum error. Yamaha should make all this old internal tone module source code available so we can find what is causing these weird behaviors. They haven't sold a new FM black box module in twenty years so they can't use the 'proprietary company secret' argument any more. And we are the only people
interested in this technology anyway.

Jeez, I HATE checksums. So useless and stupid and the cause of so much endless frustration for so many users forever.

Yeah, I know,... I should get a life. An obscure software quirk in a barely known MIDI tone module from the distant past. Big deal. But I thought that I would write it up and post it here because this is the 'newspaper of record' for the Yamaha FM tone modules. Someone in the future might run into the same situation with their SY77/TG77.
Lee Borrell
2010-01-11 07:20:03 UTC
Permalink
HAHA - yes - some of us need a life working on has-been technology that works perfectly at switch on instead of crappy windows that breaks every 5 seconds.
For my money - I would settle for a SYSx checksum problem once in a blue moon!
 
Well done on your obvious hard work - is it at all possible I can see the SYSx loader you used? I had a half written sysex editor in VB and I believe I wrote the file access section - but not the part that recieves the MIDI SYSx - I take it that your VB is operating on an existing file of SYSx?
 
I had half an inkling that the checksum problem may have been a quirk of the number of bits that remained the same/altered when moving the voice - at first - but it sounds like you are correct about there being some other marker that knows where the voice used to be.
Wierd.

--- On Sun, 10/1/10, Alan <***@yahoo.com> wrote:


From: Alan <***@yahoo.com>
Subject: [YamahaDX] Strange TG77 checksum error
To: ***@yahoogroups.com
Date: Sunday, 10 January, 2010, 6:59


 



I have noticed a strange quirk of the the SY77/TG77. This module has 64 voices in the user-customizable memory. These 64 voices are subdivided into four banks of 16 voices each. When a voice that is in Bank D, that is, a voice that is numbered 49 to 64, is moved to a lower number, the TG77 always generates a checksum error when it receives the sysex data from the PC. But any voice in
the other three banks can be moved to any other location without the TG77 giving an error. A voice that originally numbered 49-64 can be renumbered in the 49-64 range and loaded into the TG77 without a checksum error. But any voice 49-64 can't be changed to, say, voice 9 and be reloaded without a giving checksum error. Voice 9 can be changed to voice 64 and reloaded without problem.

The checksum itself is correct in all the instances. I wrote a small Visual Basic program to open a sysex file of the voice data and calculate the checksum when the voice location is adjusted. I always get the original checksum when the new voice location is the same as the original location, so the calculation code is correct (7-bit twos-complement of the sum of the bytes between offset #6 and the EOX 0xF7).

The voice's location is fixed in the voice sysex data at offset 0x1f (starting at offset 0, which is 0xF0). Adjusting this byte changes the location of the voice in the I-bank. The checksum has to be recalculated because the voice's location in the User memory (the I-bank) is part of the voice data.

Doing this allows the making of custom banks from the 14000 voices
that can be found on the web. Most of the voices in each of these banks are uninteresting. But each bank is in a single sysex file that fills the entire TG77 user-memory area when sent from the PC.
So you get the whole I-bank filled and only one or two good voices per file.

The way to get around this is to separate each of the 64 voices into a separate sysex file that starts with 0xf0 and ends with 0xf7. Then change the I-bank location for the good voices and send each voice to the TG77 individually. Then have the TG77 send the entire bank's data to the PC, which stores as a single new bank file.

Each voice file has a different length depending on the type of TG77 voice that it is: 1AFM, 2AWM, Drum, etc... But this doesn't tactic doesn't work if the voice is originally numbered 49-64.

There has to be some undocumented place in the sysex data that indicates that the original voice was from location 49-64. Otherwise there couldn't be this fake checksum error. Yamaha should make all this old internal tone module source code available so we can find what is causing these weird behaviors. They haven't sold a new FM black box module in twenty years so they can't use the 'proprietary company secret' argument any more. And we are the only people
interested in this technology anyway.

Jeez, I HATE checksums. So useless and stupid and the cause of so much endless frustration for so many users forever.

Yeah, I know,... I should get a life. An obscure software quirk in a barely known MIDI tone module from the distant past. Big deal. But I thought that I would write it up and post it here because this is the 'newspaper of record' for the Yamaha FM tone modules. Someone in the future might run into the same situation with their SY77/TG77.
bernard.escaillas
2010-01-11 14:14:23 UTC
Permalink
Hello,

I don't have a TG77 but i have worked on other Yamaha modules midi implementation. So after reading your message i decided to download the TG77 midi doc from Yamaha's to have a look at it.

Gash, i hate these LM_* messages ! It reminds me of the time i spent developping the Dx11/Tx81z editor.
(Yamaha has the worst midi implementation i have ever found around... better Alesis or Korg for that matter )

Anyway, i found some strange things that may relate to your problem :
the manual states (page 12 and following) that some voices cannot be loaded outside the $30-3F memory number range depending of their architecture. 4AFM and 2AFM_2AWM for instance. If that make sense for you, the bank D (locations 48-63 ) may be reserved for these sounds ? So relocation patches is not possible at all between banks A,B,C to bank D ?
Alan Probandt
2010-01-11 16:09:02 UTC
Permalink
I looked at the TG77 MIDI spec as you suggested and saw that cryptic little note that I overlooked before. The voices that are in range 49-64 and have four elements may the ones that can't be relocated due to internal memory configurations. Well, if I keep the TG77, I'll just have to keep those voices in that range.

Thanks for the tip.

By the way, I think that the Alesis sysex is the most complex that I've ever seen. On the S4 and Nanosynth, every parameter is compacted inside a byte or split across two bytes. For example, a parameter with range from 0 to 31 that has five bits. It might have two bits in one byte and the other three bits in another byte. And every one of the hundred parameters is like this. Programmers being too cute. Even back in 1990 there was no need for this kind of nonsense.

I downloaded a file that has about 14000 TG77 voices and have listened to about a third of them. They all have that brittle high-end FM sound quality to them along with early 1990s-synth 'bells, choir, and ghost wind' novelty wavetable-combo uselessness about them.

Between the lack of free working editors and the absurd MIDI programming complications, I'm about to give up on old Yamaha FM synths. I'll keep one or two small ROMplers and the old TQ5 4-op+effects FM box and sell off all the rest on eBay. Prices are rather high for old synths now and I might take advantage of that before the economy collapses and no one has any money for these things.
Alan Probandt
2010-01-11 15:50:24 UTC
Permalink
Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes(1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCount As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFile As Integer
Dim iReNumVoiceByteCount As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginning As Long, lDataSum As Long


Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click()
    btnSplit.Visible = False
   
    CommonDialog1.ShowOpen ' select and load a voice file
    If CommonDialog1.FileName = "" Then Exit Sub
    iReNumVoiceSysExFile = FreeFile
    Open CommonDialog1.FileName For Binary Access Read As #iReNumVoiceSysExFile
   
    NewNumFileNameStr = CommonDialog1.FileName ' full path name
    iName_NumPos = InStrRev(NewNumFileNameStr, "\")
    Name_NumStr = Right$(NewNumFileNameStr, Len(NewNumFileNameStr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True

    iReNumVoiceByteCount = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFile, , databyte
        ReNumVoiceBytes(iReNumVoiceByteCount) = databyte
        iReNumVoiceByteCount = iReNumVoiceByteCount + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber.Text = CStr(ReNumVoiceBytes(&H1F)) + 1
    Close iReNumVoiceSysExFile
   
End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes() from btnReNum_Click().

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click()
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum.Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes(iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCount - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes(iReNumVoiceByteCount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFile
    For i = 0 To iReNumVoiceByteCount - 1
        Put #iReNumVoiceSysExFile, , ReNumVoiceBytes(i)
    Next i
    Close iReNumVoiceSysExFile
    txtOrgNumber.Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click()
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCount = 0
lOffsetFromBeginning = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1.FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1.FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCount = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoicesByteCount) = databyte
        iThisVoicesByteCount = iThisVoicesByteCount + 1
        lOffsetFromBeginning = lOffsetFromBeginning + 1
    Loop Until databyte = &HF7

    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesName)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoicesName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoicesName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoicesName, i, 1))) < &H41 And (Asc(Mid$(ThisVoicesName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoicesName, i, 1))) < &H61 And (Asc(Mid$(ThisVoicesName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCount) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCount - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1

    bOriginalCkSum = VoiceBytes(iThisVoicesByteCount - 2)
    txtOrgNumber.Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCount - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1.FileName, Len(CommonDialog1.FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i); Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click()
    End
End Sub
charlie from PARRY
2010-01-11 16:39:54 UTC
Permalink
i hate visual basic ........ this crap is code eh?,

what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...

thanks for code ...

i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
and the performance dump is the same size ,,,,

crazy@!

my tip may be to begin indexing files resad into arrays and find out if they posses a sys ex header
or if they are just rew "header-less data"

charles
----- Original Message -----
From: Alan Probandt
To: ***@yahoogroups.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files




Yes, You're right about appreciating technology that works 95% of the time. We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/tg77. I have no idea how to send and receive MIDI data using Microsoft Windows APIs. One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

Below is the VB procedures for working with these SY/TG77 bank files. The window display is just a few buttons and text boxes. The split button breaks the bank file into 64 voice files in a new folder. The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data. The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes(1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCount As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFile As Integer
Dim iReNumVoiceByteCount As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginning As Long, lDataSum As Long


Private Sub Form_Load()
btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice. The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data. The checksum must also be recalculated. This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array. The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click()
btnSplit.Visible = False

CommonDialog1.ShowOpen ' select and load a voice file
If CommonDialog1.FileName = "" Then Exit Sub
iReNumVoiceSysExFile = FreeFile
Open CommonDialog1.FileName For Binary Access Read As #iReNumVoiceSysExFile

NewNumFileNameStr = CommonDialog1.FileName ' full path name
iName_NumPos = InStrRev(NewNumFileNameStr, "\")
Name_NumStr = Right$(NewNumFileNameStr, Len(NewNumFileNameStr) - iName_NumPos) ' remove path
NameStr = Right$(Name_NumStr, Len(Name_NumStr) - 3) ' remove file extension
btnDoRenum.Visible = True

iReNumVoiceByteCount = 0
Do ' load all the bytes for this individual voice into an array
Get #iReNumVoiceSysExFile, , databyte
ReNumVoiceBytes(iReNumVoiceByteCount) = databyte
iReNumVoiceByteCount = iReNumVoiceByteCount + 1
Loop Until databyte = &HF7

txtOrgNumber.Text = CStr(ReNumVoiceBytes(&H1F)) + 1
Close iReNumVoiceSysExFile

End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes() from btnReNum_Click().

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click()
If txtNewNum.Text = "" Then
MsgBox ("New Voice Number textbox is blank. Enter 1-64")
Exit Sub
End If
bNewNumber = (CByte(txtNewNum.Text)) - 1
ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array

' calculate CheckSum for the sysex block with new I-bank location
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + ReNumVoiceBytes(iPointer)
iPointer = iPointer + 1
Loop Until iPointer = iReNumVoiceByteCount - 2
bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
bCS1 = Not bCheckSum
bCS1a = bCS1 And 127
BCS2 = bCS1a + 1
bCS3 = BCS2 And 127
ReNumVoiceBytes(iReNumVoiceByteCount - 2) = bCS3 ' update the checksum value in the sysex block

NewNumStr = CStr(bNewNumber + 1)
' put new location number at beginning of the file name for the sysex block
If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
NewNumFileNameStr = NewNumStr & "_" & NameStr
Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFile
For i = 0 To iReNumVoiceByteCount - 1
Put #iReNumVoiceSysExFile, , ReNumVoiceBytes(i)
Next i
Close iReNumVoiceSysExFile
txtOrgNumber.Text = " "
txtNewNum.Text = " "
btnSplit.Visible = True
btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click()
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCount = 0
lOffsetFromBeginning = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1.FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1.FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
ThisVoicesName = ""
iThisVoicesByteCount = 0

Do ' load all the bytes for this individual voice into an array
Get #iBigSysExFile, , databyte
VoiceBytes(iThisVoicesByteCount) = databyte
iThisVoicesByteCount = iThisVoicesByteCount + 1
lOffsetFromBeginning = lOffsetFromBeginning + 1
Loop Until databyte = &HF7

For i = &H21 To &H2A ' load the voice name chars into a string
VoiceChar = VoiceBytes(i)
ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
Next i

ThisVoicesName = Trim$(ThisVoicesName)
' convert invalid filename characters to underscore

For i = 1 To Len(ThisVoicesName)
If (Asc(Mid$(ThisVoicesName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoicesName, i, 1))) > &H7A Then
Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoicesName, i, 1))) < &H41 And (Asc(Mid$(ThisVoicesName, i, 1))) > &H39 Then
Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoicesName, i, 1))) < &H61 And (Asc(Mid$(ThisVoicesName, i, 1))) > &H5A Then
Mid$(ThisVoicesName, i, 1) = Chr(&H5F)
End If
Next i ' convert invalid filename chars for loop

' add this voice's name to the list of all the voice names found in the bank file
VoiceNames(bVoiceCount) = ThisVoicesName

' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
iLittleSysExFile = FreeFile
LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
Open LittleFileName For Binary Access Write As #iLittleSysExFile
For i = 0 To iThisVoicesByteCount - 1
Put #iLittleSysExFile, , VoiceBytes(i)
Next i
Close iLittleSysExFile
bVoiceCount = bVoiceCount + 1

bOriginalCkSum = VoiceBytes(iThisVoicesByteCount - 2)
txtOrgNumber.Text = CStr(VoiceBytes(&H1F))

' calculate CheckSum and compare to original checksum in file
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + VoiceBytes(iPointer)
iPointer = iPointer + 1
Loop Until iPointer = iThisVoicesByteCount - 2
bCheckSum = lDataSum And &H7F
bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")

Loop Until bVoiceCount = 64 ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1.FileName, Len(CommonDialog1.FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
Print #iVoiceListFile, i + 1; " "; VoiceNames(i); Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click()
End
End Sub
Dale (Inquisitor Betrayer)
2010-01-11 17:44:59 UTC
Permalink
if you can, drop the vb and go c or c#
http://www.codeproject.com/KB/audio-video/midiwrapper.aspx

VB
http://support.microsoft.com/default.aspx/kb/141756

VB again
http://cs-netlab-01.lynchburg.edu/courses/VB/Samples/Musicman/MidiDocs/highmidi.htm

http://www.ex-designz.net/apicat.asp?apicat=35

good luck

dale

----- Original Message -----
From: charlie from PARRY




i hate visual basic ........ this crap is code eh?,

what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...

thanks for code ...

i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
and the performance dump is the same size ,,,,

crazy@!

my tip may be to begin indexing files resad into arrays and find out if they posses a sys ex header
or if they are just rew "header-less data"

charles
----- Original Message -----
From: Alan Probandt

Yes, You're right about appreciating technology that works 95% of the time. We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/tg77. I have no idea how to send and receive MIDI data using Microsoft Windows APIs. One <snip>
Lee Borrell
2010-01-13 14:56:24 UTC
Permalink
Thanks for those.

--- On Mon, 11/1/10, Dale (Inquisitor Betrayer) <***@inquisitorbetrayer.com> wrote:


From: Dale (Inquisitor Betrayer) <***@inquisitorbetrayer.com>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 17:44


 




if you can, drop the vb and go c or c#
http://www.codeproj ect.com/KB/ audio-video/ midiwrapper. aspx
 
VB
http://support. microsoft. com/default. aspx/kb/141756 
 
VB again
http://cs-netlab- 01.lynchburg. edu/courses/ VB/Samples/ Musicman/ MidiDocs/ highmidi. htm
 
http://www.ex- designz.net/ apicat.asp? apicat=35
 
good luck
 
dale
 

----- Original Message -----
From: charlie from PARRY
 
i hate visual basic ........ this crap is code eh?,
 
 what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...
 
thanks for code ...
 
i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
 and the performance dump is the same size ,,,,
 
crazy@!
 
my tip may be to begin indexing files resad into arrays  and find out if they posses a sys ex header
or if they are just rew "header-less data"
 
charles

----- Original Message -----
From: Alan Probandt
 



Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One <snip>





 
Lee Borrell
2010-01-13 14:54:55 UTC
Permalink
With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.
 
Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.
 
VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.
 
There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <***@sympatico.ca> wrote:


From: charlie from PARRY <***@sympatico.ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 16:39


 




i hate visual basic ........ this crap is code eh?,
 
 what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...
 
thanks for code ...
 
i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
 and the performance dump is the same size ,,,,
 
crazy@!
 
my tip may be to begin indexing files resad into arrays  and find out if they posses a sys ex header
or if they are just rew "header-less data"
 
charles

----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files





Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
    btnSplit.Visible = False
   
    CommonDialog1. ShowOpen ' select and load a voice file
    If CommonDialog1. FileName = "" Then Exit Sub
    iReNumVoiceSysExFil e = FreeFile
    Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le
   
    NewNumFileNameStr = CommonDialog1. FileName ' full path name
    iName_NumPos = InStrRev(NewNumFile NameStr, "\")
    Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True

    iReNumVoiceByteCoun t = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFi le, , databyte
        ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
        iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
    Close iReNumVoiceSysExFil e
   
End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum. Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCoun t - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
    For i = 0 To iReNumVoiceByteCoun t - 1
        Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
    Next i
    Close iReNumVoiceSysExFil e
    txtOrgNumber. Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCoun t = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoi cesByteCount) = databyte
        iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
        lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
    Loop Until databyte = &HF7

    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesNam e)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCo unt) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCoun t - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1

    bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
    txtOrgNumber. Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer )
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCoun t - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
    End
End Sub
charlie from PARRY
2010-01-13 22:11:58 UTC
Permalink
hopefully the last comment i made was taken as a compliment and not an insulte ,,
who ever writes in this" vb "
needs a good slap on the back cause i can't , ... thats for sure !!!

internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.


why the dx/tx periphreals are so appling to me ,
they never change ,(no conflicts with the structures,)
it has given us the possibilities to create music over many generations without this constant "external reference"
or convertion adaption
roland stuff is decent , but i began on a dx7 and atari.

thanks
charles

i kinda skimmed thru the blog , it was quick.

----- Original Message -----
From: Lee Borrell
To: ***@yahoogroups.com
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files




With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.

Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.

VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.

There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <***@sympatico.ca> wrote:


From: charlie from PARRY <***@sympatico.ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 16:39



i hate visual basic ........ this crap is code eh?,

what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...

thanks for code ...

i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
and the performance dump is the same size ,,,,

crazy@!

my tip may be to begin indexing files resad into arrays and find out if they posses a sys ex header
or if they are just rew "header-less data"

charles
----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files


Yes, You're right about appreciating technology that works 95% of the time. We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77. I have no idea how to send and receive MIDI data using Microsoft Windows APIs. One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

Below is the VB procedures for working with these SY/TG77 bank files. The window display is just a few buttons and text boxes. The split button breaks the bank file into 64 voice files in a new folder. The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data. The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice. The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data. The checksum must also be recalculated. This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array. The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
btnSplit.Visible = False

CommonDialog1. ShowOpen ' select and load a voice file
If CommonDialog1. FileName = "" Then Exit Sub
iReNumVoiceSysExFil e = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le

NewNumFileNameStr = CommonDialog1. FileName ' full path name
iName_NumPos = InStrRev(NewNumFile NameStr, "\")
Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
btnDoRenum.Visible = True

iReNumVoiceByteCoun t = 0
Do ' load all the bytes for this individual voice into an array
Get #iReNumVoiceSysExFi le, , databyte
ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
Loop Until databyte = &HF7

txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
Close iReNumVoiceSysExFil e

End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
If txtNewNum.Text = "" Then
MsgBox ("New Voice Number textbox is blank. Enter 1-64")
Exit Sub
End If
bNewNumber = (CByte(txtNewNum. Text)) - 1
ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array

' calculate CheckSum for the sysex block with new I-bank location
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
iPointer = iPointer + 1
Loop Until iPointer = iReNumVoiceByteCoun t - 2
bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
bCS1 = Not bCheckSum
bCS1a = bCS1 And 127
BCS2 = bCS1a + 1
bCS3 = BCS2 And 127
ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3 ' update the checksum value in the sysex block

NewNumStr = CStr(bNewNumber + 1)
' put new location number at beginning of the file name for the sysex block
If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
NewNumFileNameStr = NewNumStr & "_" & NameStr
Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
For i = 0 To iReNumVoiceByteCoun t - 1
Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
Next i
Close iReNumVoiceSysExFil e
txtOrgNumber. Text = " "
txtNewNum.Text = " "
btnSplit.Visible = True
btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
ThisVoicesName = ""
iThisVoicesByteCoun t = 0

Do ' load all the bytes for this individual voice into an array
Get #iBigSysExFile, , databyte
VoiceBytes(iThisVoi cesByteCount) = databyte
iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
Loop Until databyte = &HF7

For i = &H21 To &H2A ' load the voice name chars into a string
VoiceChar = VoiceBytes(i)
ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
Next i

ThisVoicesName = Trim$(ThisVoicesNam e)
' convert invalid filename characters to underscore

For i = 1 To Len(ThisVoicesName)
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
Next i ' convert invalid filename chars for loop

' add this voice's name to the list of all the voice names found in the bank file
VoiceNames(bVoiceCo unt) = ThisVoicesName

' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
iLittleSysExFile = FreeFile
LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
Open LittleFileName For Binary Access Write As #iLittleSysExFile
For i = 0 To iThisVoicesByteCoun t - 1
Put #iLittleSysExFile, , VoiceBytes(i)
Next i
Close iLittleSysExFile
bVoiceCount = bVoiceCount + 1

bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
txtOrgNumber. Text = CStr(VoiceBytes(&H1F))

' calculate CheckSum and compare to original checksum in file
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + VoiceBytes(iPointer )
iPointer = iPointer + 1
Loop Until iPointer = iThisVoicesByteCoun t - 2
bCheckSum = lDataSum And &H7F
bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")

Loop Until bVoiceCount = 64 ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
End
End Sub
Lee Borrell
2010-01-14 14:41:32 UTC
Permalink
Be assured- VB is not my favourite language - and you are correct - the object is to stick to the synths not get bogged down in programming languages- however - when it comes to SYSx sometimes its hard not to - as off the shelf programs tend not to do exactly what you want.
As you say- the Commodore/Atari base- offers none of the levels of interfacing that plagues the PC - and my OS is there at switch on instead of waiting half an hour for XP to become useable.
Thubs up to DX/TX - but as has just been said - seems there are even minor variations in tabling banks that can cause SYSx problems.
One of these days I might actually finish programming- if I ever find the time to do any- perhaps its easier to just download others works - maybe I am lazy in my old age. I have not even tried the Atari one I downloaded yet - as it seems to do exactly what I was trying to do on the CBM.
If I had more patience and time I might have followed up the VB angle - when I take a breath perhaps I'l run thru Alan's code and refresh my memory.
 
 
hopefully the last comment i made was taken as a compliment and not an insulte ,, 
who ever writes in this"  vb "
needs a good slap on the back cause i can't , ... thats for sure !!!
 
  internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.
 
 
 why the dx/tx periphreals are so appling to me  ,
 they never change ,(no conflicts with the structures,)
it  has given us the possibilities to create music over many generations without this constant "external reference"
or convertion  adaption
roland stuff is decent , but i began on a dx7   and atari.
 
thanks
charles 
 
i kinda skimmed thru the blog , it was quick.
 

----- Original Message -----
From: Lee Borrell
To: ***@yahoogroup s.com
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files






With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.
 
Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.
 
VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.
 
There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <charles.copp@ sympatico. ca> wrote:


From: charlie from PARRY <charles.copp@ sympatico. ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroup s.com
Date: Monday, 11 January, 2010, 16:39


 


i hate visual basic ........ this crap is code eh?,
 
 what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...
 
thanks for code ...
 
i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
 and the performance dump is the same size ,,,,
 
crazy@!
 
my tip may be to begin indexing files resad into arrays  and find out if they posses a sys ex header
or if they are just rew "header-less data"
 
charles

----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files





Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
    btnSplit.Visible = False
   
    CommonDialog1. ShowOpen ' select and load a voice file
    If CommonDialog1. FileName = "" Then Exit Sub
    iReNumVoiceSysExFil e = FreeFile
    Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le
   
    NewNumFileNameStr = CommonDialog1. FileName ' full path name
    iName_NumPos = InStrRev(NewNumFile NameStr, "\")
    Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True

    iReNumVoiceByteCoun t = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFi le, , databyte
        ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
        iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
    Close iReNumVoiceSysExFil e
   
End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum. Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCoun t - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
    For i = 0 To iReNumVoiceByteCoun t - 1
        Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
    Next i
    Close iReNumVoiceSysExFil e
    txtOrgNumber. Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCoun t = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoi cesByteCount) = databyte
        iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
        lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
    Loop Until databyte = &HF7

    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesNam e)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCo unt) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCoun t - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1

    bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
    txtOrgNumber. Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer )
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCoun t - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
    End
End Sub
Alan Probandt
2010-01-15 01:07:15 UTC
Permalink
Hello,
  I write in Visual Basic only when I need to get something done that can only be done on the PC.  It is a vast language and I don't understand why people are so against it.
 
  In this case, I needed to split some TG77 bank files into smaller elements.  Each bank file has 64 blocks starting with 0xf0 and ending with 0xf7.  And I needed to recalculate the checksum.  Visual Basic works well for this kind of thing.  It's not all that hard, after all, it is BASIC upgraded to a point-and-click computer screen.
 
  I did a really dumb tone module thing last week.  I bought a sampler module on eBay.  It arrived but there is absolutely no way to play it.  There is no preset sound in it at all and it makes no sound, not even a sine wave.  It has a floppy drive and a SCSI connector, both obselete technologies that are far more trouble than they are worth to try to get working.  This individual Peavey SP is in good shape and it was only $20, but what a dud.  There doesn't seem to be anything that can be done with it.  Hopefully I can resell it for a few bucks.  What a total turkey.  Whatever dumb things the synth tone module makers did, they never did anything so stupid as produce an 'electronic musical instrument' that can make no sound whatever in its factory-new condition.  This bozo machine has to be loaded with waveforms by the user but doesn't provide any means to do so.  Of course, of Course, the floppy format is not compatable to any of the
popular computer formats of the time (PC, Mac, or Atari ST).  The Peavey 'engineers' probably thought that they were hot stuff in coming up with a totally bizarre floppy format that packs maybe 5% more data onto a disk but can't be read or written to by any computer.  Where was management when this was released?
 
  I know that there's a 'great website' for the Peavey SP, but it doesn't change the fact that every possible decision in the design of this machine was wrong.  What a tragedy.  The Yamaha black boxes will still be around in a hundred years like Model T Fords and Jaguar XKEs just because they are such intriguing and playful machines.  All the samplers will be long gone.   A zombie technology... born already dead.


--- On Thu, 1/14/10, Lee Borrell <***@yahoo.co.uk> wrote:


From: Lee Borrell <***@yahoo.co.uk>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Thursday, January 14, 2010, 6:41 AM




















Be assured- VB is not my favourite language - and you are correct - the object is to stick to the synths not get bogged down in programming languages- however - when it comes to SYSx sometimes its hard not to - as off the shelf programs tend not to do exactly what you want.
As you say- the Commodore/Atari base- offers none of the levels of interfacing that plagues the PC - and my OS is there at switch on instead of waiting half an hour for XP to become useable.
Thubs up to DX/TX - but as has just been said - seems there are even minor variations in tabling banks that can cause SYSx problems.
One of these days I might actually finish programming- if I ever find the time to do any- perhaps its easier to just download others works - maybe I am lazy in my old age. I have not even tried the Atari one I downloaded yet - as it seems to do exactly what I was trying to do on the CBM.
If I had more patience and time I might have followed up the VB angle - when I take a breath perhaps I'l run thru Alan's code and refresh my memory.
 
 
hopefully the last comment i made was taken as a compliment and not an insulte ,, 
who ever writes in this"  vb "
needs a good slap on the back cause i can't , ... thats for sure !!!
 
  internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.
 
 
 why the dx/tx periphreals are so appling to me  ,
 they never change ,(no conflicts with the structures,)
it  has given us the possibilities to create music over many generations without this constant "external reference"
or convertion  adaption
roland stuff is decent , but i began on a dx7   and atari.
 
thanks
charles 
 
i kinda skimmed thru the blog , it was quick.
 

----- Original Message -----
From: Lee Borrell
To: ***@yahoogroup s.com
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files






With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.
 
Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.
 
VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.
 
There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <charles.copp@ sympatico. ca> wrote:


From: charlie from PARRY <charles.copp@ sympatico. ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroup s.com
Date: Monday, 11 January, 2010, 16:39


 


i hate visual basic ........ this crap is code eh?,
 
 what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...
 
thanks for code ...
 
i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
 and the performance dump is the same size ,,,,
 
crazy@!
 
my tip may be to begin indexing files resad into arrays  and find out if they posses a sys ex header
or if they are just rew "header-less data"
 
charles

----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files





Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
    btnSplit.Visible = False
   
    CommonDialog1. ShowOpen ' select and load a voice file
    If CommonDialog1. FileName = "" Then Exit Sub
    iReNumVoiceSysExFil e = FreeFile
    Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le
   
    NewNumFileNameStr = CommonDialog1. FileName ' full path name
    iName_NumPos = InStrRev(NewNumFile NameStr, "\")
    Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True

    iReNumVoiceByteCoun t = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFi le, , databyte
        ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
        iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
    Close iReNumVoiceSysExFil e
   
End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum. Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCoun t - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
    For i = 0 To iReNumVoiceByteCoun t - 1
        Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
    Next i
    Close iReNumVoiceSysExFil e
    txtOrgNumber. Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCoun t = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoi cesByteCount) = databyte
        iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
        lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
    Loop Until databyte = &HF7

    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesNam e)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCo unt) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCoun t - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1

    bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
    txtOrgNumber. Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer )
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCoun t - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
    End
End Sub
thenewyorkcowboy
2010-01-15 16:20:48 UTC
Permalink
Yes Alan, I agree with you entirely. I think Peavey backpedaled a bit and what you get for the SP you might want to try and locate a SX.

http://www.dissidents.com/products.htm#Products%20SXVirtual
Post by bernard.escaillas
Hello,
  I write in Visual Basic only when I need to get something done that can only be done on the PC.  It is a vast language and I don't understand why people are so against it.
 
  In this case, I needed to split some TG77 bank files into smaller elements.  Each bank file has 64 blocks starting with 0xf0 and ending with 0xf7.  And I needed to recalculate the checksum.  Visual Basic works well for this kind of thing.  It's not all that hard, after all, it is BASIC upgraded to a point-and-click computer screen.
 
  I did a really dumb tone module thing last week.  I bought a sampler module on eBay.  It arrived but there is absolutely no way to play it.  There is no preset sound in it at all and it makes no sound, not even a sine wave.  It has a floppy drive and a SCSI connector, both obselete technologies that are far more trouble than they are worth to try to get working.  This individual Peavey SP is in good shape and it was only $20, but what a dud.  There doesn't seem to be anything that can be done with it.  Hopefully I can resell it for a few bucks.  What a total turkey.  Whatever dumb things the synth tone module makers did, they never did anything so stupid as produce an 'electronic musical instrument' that can make no sound whatever in its factory-new condition.  This bozo machine has to be loaded with waveforms by the user but doesn't provide any means to do so.  Of course, of Course, the floppy format is not compatable to any of the
popular computer formats of the time (PC, Mac, or Atari ST).  The Peavey 'engineers' probably thought that they were hot stuff in coming up with a totally bizarre floppy format that packs maybe 5% more data onto a disk but can't be read or written to by any computer.  Where was management when this was released?
 
  I know that there's a 'great website' for the Peavey SP, but it doesn't change the fact that every possible decision in the design of this machine was wrong.  What a tragedy.  The Yamaha black boxes will still be around in a hundred years like Model T Fords and Jaguar XKEs just because they are such intriguing and playful machines.  All the samplers will be long gone.   A zombie technology... born already dead.
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
Date: Thursday, January 14, 2010, 6:41 AM
Be assured- VB is not my favourite language - and you are correct - the object is to stick to the synths not get bogged down in programming languages- however - when it comes to SYSx sometimes its hard not to - as off the shelf programs tend not to do exactly what you want.
As you say- the Commodore/Atari base- offers none of the levels of interfacing that plagues the PC - and my OS is there at switch on instead of waiting half an hour for XP to become useable.
Thubs up to DX/TX - but as has just been said - seems there are even minor variations in tabling banks that can cause SYSx problems.
One of these days I might actually finish programming- if I ever find the time to do any- perhaps its easier to just download others works - maybe I am lazy in my old age. I have not even tried the Atari one I downloaded yet - as it seems to do exactly what I was trying to do on the CBM.
If I had more patience and time I might have followed up the VB angle - when I take a breath perhaps I'l run thru Alan's code and refresh my memory.
 
 
hopefully the last comment i made was taken as a compliment and not an insulte ,, 
who ever writes in this"  vb "
needs a good slap on the back cause i can't , ... thats for sure !!!
 
  internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.
 
 
 why the dx/tx periphreals are so appling to me  ,
 they never change ,(no conflicts with the structures,)
it  has given us the possibilities to create music over many generations without this constant "external reference"
or convertion  adaption
roland stuff is decent , but i began on a dx7   and atari.
 
thanks
charles 
 
i kinda skimmed thru the blog , it was quick.
 
----- Original Message -----
From: Lee Borrell
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.
 
Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.
 
VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.
 
There's pros and cons both ways.
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
Date: Monday, 11 January, 2010, 16:39
 
i hate visual basic ........ this crap is code eh?,
 
 what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...
 
thanks for code ...
 
i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
 and the performance dump is the same size ,,,,
 
 
my tip may be to begin indexing files resad into arrays  and find out if they posses a sys ex header
or if they are just rew "header-less data"
 
charles
----- Original Message -----
From: Alan Probandt
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files
Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.
  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.
  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.
'Yamaha SY77/TG77 tone module voice bank mini-librarian program
'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.
' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long
Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub
' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
    btnSplit.Visible = False
   
    CommonDialog1. ShowOpen ' select and load a voice file
    If CommonDialog1. FileName = "" Then Exit Sub
    iReNumVoiceSysExFil e = FreeFile
    Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le
   
    NewNumFileNameStr = CommonDialog1. FileName ' full path name
    iName_NumPos = InStrRev(NewNumFile NameStr, "\")
    Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True
    iReNumVoiceByteCoun t = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFi le, , databyte
        ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
        iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
    Close iReNumVoiceSysExFil e
   
End Sub
' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).
' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.
Private Sub btnDoRenum_Click( )
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum. Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCoun t - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
    For i = 0 To iReNumVoiceByteCoun t - 1
        Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
    Next i
    Close iReNumVoiceSysExFil e
    txtOrgNumber. Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub
' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""
' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)
Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCoun t = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoi cesByteCount) = databyte
        iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
        lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
    Loop Until databyte = &HF7
    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesNam e)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCo unt) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCoun t - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1
    bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
    txtOrgNumber. Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer )
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCoun t - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice
Close iBigSysExFile
iVoiceListFile = FreeFile
' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i
Close iVoiceListFile
End Sub
Private Sub btnEnd_Click( )
    End
End Sub
Wilson Zorn
2010-01-18 00:26:52 UTC
Permalink
Charlie you're as much the problem on this list as any others you've taken to task. I've sat in silence with your insufferable attitude as much as I can take.
----- Original Message -----
From: charlie from PARRY
To: ***@yahoogroups.com
Sent: Wednesday, January 13, 2010 2:11 PM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files





hopefully the last comment i made was taken as a compliment and not an insulte ,,
who ever writes in this" vb "
needs a good slap on the back cause i can't , ... thats for sure !!!

internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.


why the dx/tx periphreals are so appling to me ,
they never change ,(no conflicts with the structures,)
it has given us the possibilities to create music over many generations without this constant "external reference"
or convertion adaption
roland stuff is decent , but i began on a dx7 and atari.

thanks
charles

i kinda skimmed thru the blog , it was quick.

----- Original Message -----
From: Lee Borrell
To: ***@yahoogroups.com
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files


With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.

Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.

VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.

There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <***@sympatico.ca> wrote:


From: charlie from PARRY <***@sympatico.ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 16:39



i hate visual basic ........ this crap is code eh?,

what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...

thanks for code ...

i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
and the performance dump is the same size ,,,,

crazy@!

my tip may be to begin indexing files resad into arrays and find out if they posses a sys ex header
or if they are just rew "header-less data"

charles
----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files


Yes, You're right about appreciating technology that works 95% of the time. We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77. I have no idea how to send and receive MIDI data using Microsoft Windows APIs. One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

Below is the VB procedures for working with these SY/TG77 bank files. The window display is just a few buttons and text boxes. The split button breaks the bank file into 64 voice files in a new folder. The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data. The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice. The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data. The checksum must also be recalculated. This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array. The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
btnSplit.Visible = False

CommonDialog1. ShowOpen ' select and load a voice file
If CommonDialog1. FileName = "" Then Exit Sub
iReNumVoiceSysExFil e = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le

NewNumFileNameStr = CommonDialog1. FileName ' full path name
iName_NumPos = InStrRev(NewNumFile NameStr, "\")
Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
btnDoRenum.Visible = True

iReNumVoiceByteCoun t = 0
Do ' load all the bytes for this individual voice into an array
Get #iReNumVoiceSysExFi le, , databyte
ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
Loop Until databyte = &HF7

txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
Close iReNumVoiceSysExFil e

End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
If txtNewNum.Text = "" Then
MsgBox ("New Voice Number textbox is blank. Enter 1-64")
Exit Sub
End If
bNewNumber = (CByte(txtNewNum. Text)) - 1
ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array

' calculate CheckSum for the sysex block with new I-bank location
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
iPointer = iPointer + 1
Loop Until iPointer = iReNumVoiceByteCoun t - 2
bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
bCS1 = Not bCheckSum
bCS1a = bCS1 And 127
BCS2 = bCS1a + 1
bCS3 = BCS2 And 127
ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3 ' update the checksum value in the sysex block

NewNumStr = CStr(bNewNumber + 1)
' put new location number at beginning of the file name for the sysex block
If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
NewNumFileNameStr = NewNumStr & "_" & NameStr
Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
For i = 0 To iReNumVoiceByteCoun t - 1
Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
Next i
Close iReNumVoiceSysExFil e
txtOrgNumber. Text = " "
txtNewNum.Text = " "
btnSplit.Visible = True
btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
ThisVoicesName = ""
iThisVoicesByteCoun t = 0

Do ' load all the bytes for this individual voice into an array
Get #iBigSysExFile, , databyte
VoiceBytes(iThisVoi cesByteCount) = databyte
iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
Loop Until databyte = &HF7

For i = &H21 To &H2A ' load the voice name chars into a string
VoiceChar = VoiceBytes(i)
ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
Next i

ThisVoicesName = Trim$(ThisVoicesNam e)
' convert invalid filename characters to underscore

For i = 1 To Len(ThisVoicesName)
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
Next i ' convert invalid filename chars for loop

' add this voice's name to the list of all the voice names found in the bank file
VoiceNames(bVoiceCo unt) = ThisVoicesName

' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
iLittleSysExFile = FreeFile
LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
Open LittleFileName For Binary Access Write As #iLittleSysExFile
For i = 0 To iThisVoicesByteCoun t - 1
Put #iLittleSysExFile, , VoiceBytes(i)
Next i
Close iLittleSysExFile
bVoiceCount = bVoiceCount + 1

bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
txtOrgNumber. Text = CStr(VoiceBytes(&H1F))

' calculate CheckSum and compare to original checksum in file
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + VoiceBytes(iPointer )
iPointer = iPointer + 1
Loop Until iPointer = iThisVoicesByteCoun t - 2
bCheckSum = lDataSum And &H7F
bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")

Loop Until bVoiceCount = 64 ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
End
End Sub
charlie from PARRY
2010-01-18 03:13:10 UTC
Permalink
i'd suggest something but it appears you've missed the issue.

this is a group for disscussion of yamaha dx7 synthesizers .

i have a personal mail address for any non-group related issues or "feedbacks"

charles

----- Original Message -----
From: Wilson Zorn
To: ***@yahoogroups.com
Sent: Sunday, January 17, 2010 4:26 PM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files





Charlie you're as much the problem on this list as any others you've taken to task. I've sat in silence with your insufferable attitude as much as I can take.
----- Original Message -----
From: charlie from PARRY
To: ***@yahoogroups.com
Sent: Wednesday, January 13, 2010 2:11 PM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files



hopefully the last comment i made was taken as a compliment and not an insulte ,,
who ever writes in this" vb "
needs a good slap on the back cause i can't , ... thats for sure !!!

internal structures of the pc are so many more ways different than the atari which i always use
any how the main objective is to find users of these items and share sound banks -setups ...
not to disscus programming languages.


why the dx/tx periphreals are so appling to me ,
they never change ,(no conflicts with the structures,)
it has given us the possibilities to create music over many generations without this constant "external reference"
or convertion adaption
roland stuff is decent , but i began on a dx7 and atari.

thanks
charles

i kinda skimmed thru the blog , it was quick.

----- Original Message -----
From: Lee Borrell
To: ***@yahoogroups.com
Sent: Wednesday, January 13, 2010 6:54 AM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files


With respect - what I have seen of the ST -makes VB look easy! Perhaps it is because you have used the Atari as I have used the CBM.

Admittedly - VB is made hard because of it's dependence on DLLS and and in bits before making an EXE- the beauty of it is not having to design "buttons" and "sliders" - they are preformed. When working on the PSS series in CBM basic - I was forced to create sliders and buttons from scratch and then kept the coding to recreate the same processes again.

VB does have benefits - but my own experience of it,leads me back to using CBM - perhaps I just haven't spent enough time with it- but it was frustrating.
On the other side - the Atari programs I have downloaded seem to work first time and remain stable and not fall over because they are running on an OS that reports ERRORS back to the creator.

There's pros and cons both ways.

--- On Mon, 11/1/10, charlie from PARRY <***@sympatico.ca> wrote:


From: charlie from PARRY <***@sympatico.ca>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 16:39



i hate visual basic ........ this crap is code eh?,

what ever happened to the good old atari days of gfa basic and pascal ,,,,i know , they are making programming computers easier ...

thanks for code ...

i have my dx sys ex editor done for the atari st
but still working on the performance half of the code ,,
believ it or not a tx816
has a dump of 4104 bytes ,,,
and the performance dump is the same size ,,,,

crazy@!

my tip may be to begin indexing files resad into arrays and find out if they posses a sys ex header
or if they are just rew "header-less data"

charles
----- Original Message -----
From: Alan Probandt
To: ***@yahoogroup s.com
Sent: Monday, January 11, 2010 7:50 AM
Subject: [YamahaDX] Visual Basic to work with existing sysex files


Yes, You're right about appreciating technology that works 95% of the time. We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77. I have no idea how to send and receive MIDI data using Microsoft Windows APIs. One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

Below is the VB procedures for working with these SY/TG77 bank files. The window display is just a few buttons and text boxes. The split button breaks the bank file into 64 voice files in a new folder. The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data. The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice. The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data. The checksum must also be recalculated. This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array. The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
btnSplit.Visible = False

CommonDialog1. ShowOpen ' select and load a voice file
If CommonDialog1. FileName = "" Then Exit Sub
iReNumVoiceSysExFil e = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le

NewNumFileNameStr = CommonDialog1. FileName ' full path name
iName_NumPos = InStrRev(NewNumFile NameStr, "\")
Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
btnDoRenum.Visible = True

iReNumVoiceByteCoun t = 0
Do ' load all the bytes for this individual voice into an array
Get #iReNumVoiceSysExFi le, , databyte
ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
Loop Until databyte = &HF7

txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
Close iReNumVoiceSysExFil e

End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
If txtNewNum.Text = "" Then
MsgBox ("New Voice Number textbox is blank. Enter 1-64")
Exit Sub
End If
bNewNumber = (CByte(txtNewNum. Text)) - 1
ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array

' calculate CheckSum for the sysex block with new I-bank location
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
iPointer = iPointer + 1
Loop Until iPointer = iReNumVoiceByteCoun t - 2
bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
bCS1 = Not bCheckSum
bCS1a = bCS1 And 127
BCS2 = bCS1a + 1
bCS3 = BCS2 And 127
ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3 ' update the checksum value in the sysex block

NewNumStr = CStr(bNewNumber + 1)
' put new location number at beginning of the file name for the sysex block
If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
NewNumFileNameStr = NewNumStr & "_" & NameStr
Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
For i = 0 To iReNumVoiceByteCoun t - 1
Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
Next i
Close iReNumVoiceSysExFil e
txtOrgNumber. Text = " "
txtNewNum.Text = " "
btnSplit.Visible = True
btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
ThisVoicesName = ""
iThisVoicesByteCoun t = 0

Do ' load all the bytes for this individual voice into an array
Get #iBigSysExFile, , databyte
VoiceBytes(iThisVoi cesByteCount) = databyte
iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
Loop Until databyte = &HF7

For i = &H21 To &H2A ' load the voice name chars into a string
VoiceChar = VoiceBytes(i)
ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
Next i

ThisVoicesName = Trim$(ThisVoicesNam e)
' convert invalid filename characters to underscore

For i = 1 To Len(ThisVoicesName)
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
End If
Next i ' convert invalid filename chars for loop

' add this voice's name to the list of all the voice names found in the bank file
VoiceNames(bVoiceCo unt) = ThisVoicesName

' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
iLittleSysExFile = FreeFile
LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
Open LittleFileName For Binary Access Write As #iLittleSysExFile
For i = 0 To iThisVoicesByteCoun t - 1
Put #iLittleSysExFile, , VoiceBytes(i)
Next i
Close iLittleSysExFile
bVoiceCount = bVoiceCount + 1

bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
txtOrgNumber. Text = CStr(VoiceBytes(&H1F))

' calculate CheckSum and compare to original checksum in file
lDataSum = 0
iPointer = &H6
Do
lDataSum = lDataSum + VoiceBytes(iPointer )
iPointer = iPointer + 1
Loop Until iPointer = iThisVoicesByteCoun t - 2
bCheckSum = lDataSum And &H7F
bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")

Loop Until bVoiceCount = 64 ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
End
End Sub
Alan Probandt
2010-01-18 18:15:26 UTC
Permalink
The topic of Visual Basic and Windows MIDI programming is actually vital for the Yamaha DX group because these treasured synthesizers won't survive without good working editor programs. 

Ten-year-old crippled 'shareware' plagued with nag screens and send-$40-to-my-ancient-email-address-and-I'll-send-you-a-magic-number-to-maybe-make-my-hobby-code-editor-work just doesn't make it any more.  It rarely worked fifteen years ago: It doesn't work now, and it certainly won't work in the future.  We need free reasonable-good-quality open-source editors that work on modern PCs and can be updated to new operating systems as they are introduced.  Visual Basic is the easiest tool to use for the most prevalent OS at the time, which is Windows.  Without maintainable programs, all the DX boxes will be traded on eBay round-and-round and used less by each person until they are tossed in the landfill at the first broken wire or dead battery.

We see this now with the 'shareware' programs.  There hasn't been a single new feature or user-interface innovation in tone module editor software in twenty years.  The OS has become nearly impossible to use in the transition from simple character-based DOS and elemental mouse-click programs to Vista.

  We need an open-source general DX editor like the Prodata editor that is available for the E-Mu Proteus 2000 boxes.  Goodness knows, the E-Mu boxes should have died out when the company went south since they are little more than collections of wavetable sound effects with extensive filters and external MIDI-controller linkages.  But they live on: traded back and forth on eBay.  In the past year, I've bought and resold an Audity2000, a Proteus2000, a Planet Phatt, and a Mo'Phatt.  I don't have any of them anymore.  But the Prodata free open-source editor for Windows and Linux was invaluable for me to explore them.   Now, I have a TQ5, a TG77, an MU10, and an Alexis S4 plus, plus a half dozen $10-$20 General_MIDI orphan boxes found on eBay that no one bid on. 

 The TG77 and Alesis S4 Plus will probably go in a month or two.  They are intriguing and interesting synths, but they have no editors and are too complicated for me to spend 100 hours writing a microcontroller-based parameter changer for them.  Plus they'll bring in $350 in hard times.  The TG77 is a real beast.  It's almost as big and heavy as a microwave oven.  It makes great organ sounds. 

The Yamaha MU10 is rare and about the size of a VHS video cassette.  It has the ability to apply its effects section (like delay, chorus, and reverb) to its analog input.  So you can use the effects on an electric guitar at the same time that a sequencer is playing the synth voices.  But it has no front panel or buttons and a difficult MIDI programming scheme.  It's a great box.  Yamaha should re-introduce it with a few buttons and a little screen at a reasonable price like $69.95.  Yamaha did have an MU5 like that, but it was a turkey because it had no effects or programmablility.

  So, anyway, keep posting files and comments and tips here and the Yamaha DX boxes will continue to live on.
Lee Borrell
2010-01-18 21:12:53 UTC
Permalink
Well said - if I could only get my VB operational again I'd give it a whirl - just about to look more closely at your coding.

--- On Mon, 18/1/10, Alan Probandt <***@yahoo.com> wrote:


From: Alan Probandt <***@yahoo.com>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 18 January, 2010, 18:15


 







The topic of Visual Basic and Windows MIDI programming is actually vital for the Yamaha DX group because these treasured synthesizers won't survive without good working editor programs. 

Ten-year-old crippled 'shareware' plagued with nag screens and send-$40-to- my-ancient- email-address- and-I'll- send-you- a-magic-number- to-maybe- make-my-hobby- code-editor- work just doesn't make it any more.  It rarely worked fifteen years ago: It doesn't work now, and it certainly won't work in the future.  We need free reasonable-good- quality open-source editors that work on modern PCs and can be updated to new operating systems as they are introduced.  Visual Basic is the easiest tool to use for the most prevalent OS at the time, which is Windows.  Without maintainable programs, all the DX boxes will be traded on eBay round-and-round and used less by each person until they are tossed in the landfill at the first broken wire or dead battery.

We see this now with the 'shareware' programs.  There hasn't been a single new feature or user-interface innovation in tone module editor software in twenty years.  The OS has become nearly impossible to use in the transition from simple character-based DOS and elemental mouse-click programs to Vista.

  We need an open-source general DX editor like the Prodata editor that is available for the E-Mu Proteus 2000 boxes.  Goodness knows, the E-Mu boxes should have died out when the company went south since they are little more than collections of wavetable sound effects with extensive filters and external MIDI-controller linkages.  But they live on: traded back and forth on eBay.  In the past year, I've bought and resold an Audity2000, a Proteus2000, a Planet Phatt, and a Mo'Phatt.  I don't have any of them anymore.  But the Prodata free open-source editor for Windows and Linux was invaluable for me to explore them.   Now, I have a TQ5, a TG77, an MU10, and an Alexis S4 plus, plus a half dozen $10-$20 General_MIDI orphan boxes found on eBay that no one bid on. 

 The TG77 and Alesis S4 Plus will probably go in a month or two.  They are intriguing and interesting synths, but they have no editors and are too complicated for me to spend 100 hours writing a microcontroller- based parameter changer for them.  Plus they'll bring in $350 in hard times.  The TG77 is a real beast.  It's almost as big and heavy as a microwave oven.  It makes great organ sounds. 

The Yamaha MU10 is rare and about the size of a VHS video cassette.  It has the ability to apply its effects section (like delay, chorus, and reverb) to its analog input.  So you can use the effects on an electric guitar at the same time that a sequencer is playing the synth voices.  But it has no front panel or buttons and a difficult MIDI programming scheme.  It's a great box.  Yamaha should re-introduce it with a few buttons and a little screen at a reasonable price like $69.95.  Yamaha did have an MU5 like that, but it was a turkey because it had no effects or programmablility.

  So, anyway, keep posting files and comments and tips here and the Yamaha DX boxes will continue to live on.
charlie from PARRY
2010-01-18 22:04:52 UTC
Permalink
all i have to say is
usb or com ,,,
maybe both ...

can visual basic out put to both ports?
and then is it a baud rate our dx/yamaha boxes can activliiy pick up ?

i might give vb or qbasic or something a try but this will involve much more of a learning curve then my atari commands i allready learnt..

to add ,my editor i made does well , it has two parts and allows for many approaches to editing a voice
dump all32 or just dump one...

has possibilites to dump functions too single or \32/64 of them
and set range points lo hi for the midi in ...basically does what ever is in the manual for sys ex specs.

only trouble is some of the data listed does not pick up over single parameter tranmissions ,,and even some of the data contained in writing for my unit is incorrect...

just to mention i use a tx816 ,, slightly different but just the same as 8 dx7 in one box.

so any parts need explaned , feel free to ask .
charles


----- Original Message -----
From: Lee Borrell
To: ***@yahoogroups.com
Sent: Monday, January 18, 2010 1:12 PM
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files




Well said - if I could only get my VB operational again I'd give it a whirl - just about to look more closely at your coding.

--- On Mon, 18/1/10, Alan Probandt <***@yahoo.com> wrote:


From: Alan Probandt <***@yahoo.com>
Subject: Re: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 18 January, 2010, 18:15



The topic of Visual Basic and Windows MIDI programming is actually vital for the Yamaha DX group because these treasured synthesizers won't survive without good working editor programs.

Ten-year-old crippled 'shareware' plagued with nag screens and send-$40-to- my-ancient- email-address- and-I'll- send-you- a-magic-number- to-maybe- make-my-hobby- code-editor- work just doesn't make it any more. It rarely worked fifteen years ago: It doesn't work now, and it certainly won't work in the future. We need free reasonable-good- quality open-source editors that work on modern PCs and can be updated to new operating systems as they are introduced. Visual Basic is the easiest tool to use for the most prevalent OS at the time, which is Windows. Without maintainable programs, all the DX boxes will be traded on eBay round-and-round and used less by each person until they are tossed in the landfill at the first broken wire or dead battery.

We see this now with the 'shareware' programs. There hasn't been a single new feature or user-interface innovation in tone module editor software in twenty years. The OS has become nearly impossible to use in the transition from simple character-based DOS and elemental mouse-click programs to Vista.

We need an open-source general DX editor like the Prodata editor that is available for the E-Mu Proteus 2000 boxes. Goodness knows, the E-Mu boxes should have died out when the company went south since they are little more than collections of wavetable sound effects with extensive filters and external MIDI-controller linkages. But they live on: traded back and forth on eBay. In the past year, I've bought and resold an Audity2000, a Proteus2000, a Planet Phatt, and a Mo'Phatt. I don't have any of them anymore. But the Prodata free open-source editor for Windows and Linux was invaluable for me to explore them. Now, I have a TQ5, a TG77, an MU10, and an Alexis S4 plus, plus a half dozen $10-$20 General_MIDI orphan boxes found on eBay that no one bid on.

The TG77 and Alesis S4 Plus will probably go in a month or two. They are intriguing and interesting synths, but they have no editors and are too complicated for me to spend 100 hours writing a microcontroller- based parameter changer for them. Plus they'll bring in $350 in hard times. The TG77 is a real beast. It's almost as big and heavy as a microwave oven. It makes great organ sounds.

The Yamaha MU10 is rare and about the size of a VHS video cassette. It has the ability to apply its effects section (like delay, chorus, and reverb) to its analog input. So you can use the effects on an electric guitar at the same time that a sequencer is playing the synth voices. But it has no front panel or buttons and a difficult MIDI programming scheme. It's a great box. Yamaha should re-introduce it with a few buttons and a little screen at a reasonable price like $69.95. Yamaha did have an MU5 like that, but it was a turkey because it had no effects or programmablility.

So, anyway, keep posting files and comments and tips here and the Yamaha DX boxes will continue to live on.
Alan Probandt
2010-01-19 02:24:20 UTC
Permalink
Visual Basic ver 6 from 1998 has well-documented support for the serial COM port.  It's not really easy to work with, but it does work.  However it only works at standard baud rates like 9600, 19200, and 38400 baud.   If you have a 1990s era Yamaha with a 'to-host' interface, then you can use the serial port to communicate with the tone module using a serial port with VB6.
 
  The Windows MIDI port is never directly interfaced with by a standard compiler like Visual Basic or Visual C.  The user loads a direct-link-library (DLL) that acts as a bridge between the compiler and whatever MIDI port is available on the Windows PC.  To receive a MIDI sysex dump from a TX81Z, the user would reserve a block of memory (a buffer) for the sysex data, create another buffer that holds the sysex request string, and somehow instruct the Multi-Media DLL to output the bytes from one buffer and save the incoming bytes.  But this is all completely undocumented, nor have I ever seen a working piece of code that shows how to do it.  But it can be done because there are Windows editor programs.
  I have emailed the various programmers many times how they do this.  I either get no response or maybe an undocumented cryptic block of C++ code, which may or may not have anything to do with MIDI interfacing.  The only documentation that the pinheads at Microsoft will release about MIDI is how to play a MIDI file using DLLs.  Linux works more-or-less the same way, if I understand correctly, which I don't.  The Mac people don't understand why any user would want to do anything with code when it is just such easier to simply pay $600 for an 'insanely great' program that does it for you so much better than 'Windows junk' ever could.  The idea that some people can't drop $600 on a simple program is beyond the comprehension of the people who use Macs.

  With 1990s DOS and an MPU401 MIDI card, you would read/write directly to a pair of Input/Output ports.  Each port had a status register.  If a bit in the status register was set, then you could write a byte to the output port and it would zoom out the MIDI card to the synth.  If a different bit in the status reg was set, then the synth sent you a MIDI byte. Better read it quickly before the next one arrived. To get a sysex dump, just read bytes until the value 0xF7 arrived.

  With a stand-alone microcontroller like a PIC or an AVR Aurdino you have a programmable UART, which is a serial port.  There is a formula to get the UART to send and receive data at 31250 baud that depends on the controller's system clock speed.  The clock speed is usually slow like 8 megahertz.  Then the UART acts like the MPU401 card. Often there is a memory size limit in the microcontroller.  For instance, the AVR Mega88 IC used in the Aurdino has only 1024 bytes of RAM.  This prevents it from receiving and storing large sysex dumps from the synth, such as whole banks of voices.

 Microcontroller boards usually have small LCD character displays, 16 chars by 2 rows is common. These are inexpensive ($3-$8) and have easy-to-use standard interfaces.  Graphic LCDs of 128 pixels by 64 pixels are about $20 and are more difficult to program. PC standard PS2 QWERTY keyboards are easy to interface to microcontrollers and a mouse is less easy, but not too difficult. Now almost all microcontrollers have built-in analog-to-digital converters so it is easy to add potentiometers (knobs), encoders (knobs that spin endlessly) and sensors.  MIcrocontroller chips cost between $1 and $5, but they will need a programmer and development/debug system that is usually about $100.  AVRs can be programmed directly from the PC parallel port with inexpensive (@$10) interfaces or the USB on the PC (a $20 interface).  The development/debug programming tools, assemblers, C compilers, and datasheet documentation is all freely available from the
manufacturers' websites.  The chips themselves are available from DigiKey (a major US parts distributor) or from eBay auctions in small quantities.  Writing and debugging MIDI programs on them can be very time consuming, but it might lead to a new career as an embedded-systems developer.
din5pin
2010-01-19 14:21:10 UTC
Permalink
Hi Group. I've been lurking here for quite a while. I decided to join since the topic of programming for the DX models has ramped up lately. Among my MIDI gear is a YS200 (as many of you know, the TQ5 is the keyboard-less version). Long ago I wrote a DOS-based editor/librarian for the YS, but had thought about "modernizing" it. With that in mind, I collected links to various info that might be useful. Unfortunately, I haven't had the time to devote to MIDI projects.

Much of the below concerns VB, although there's C (+, ++, #) related material as well. I didn't look over any of it in detail and can't vouch for its value, but I hope some of it is helpful.

http://support.microsoft.com/kb/q181360/

http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/
http://www.codeguru.com/code/legacy/vb_multimedia/2138_midi.zip
http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/2138_faq.htm

http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1097/
http://www.codeguru.com/code/legacy/vb_multimedia/2041_BDcode.zip

http://www.lesliesanford.com/Programming/MIDIToolkit.shtml
http://www.lesliesanford.com/Programming/SourceFiles/MIDIToolkit.zip

http://home.modemss.brisnet.org.au/~mlevoi/midi.html

http://midishare.sourceforge.net/

http://www.harmony-central.com/MIDI/midivbx.zip
http://www.harmony-central.com/MIDI/midilib.zip
charlie from PARRY
2010-01-19 23:32:02 UTC
Permalink
thanks din5pin , alot of thuis code is like pascal and basic mixed together
,, is it VB code?
i never used vb at all

charles


----- Original Message -----
From: "din5pin" <***@yahoo.com>
To: <***@yahoogroups.com>
Sent: Tuesday, January 19, 2010 6:21 AM
Subject: [YamahaDX] Re: Visual Basic to work with existing sysex files
Post by din5pin
Hi Group. I've been lurking here for quite a while. I decided to join
since the topic of programming for the DX models has ramped up lately. Among
my MIDI gear is a YS200 (as many of you know, the TQ5 is the keyboard-less
version). Long ago I wrote a DOS-based editor/librarian for the YS, but had
thought about "modernizing" it. With that in mind, I collected links to
various info that might be useful. Unfortunately, I haven't had the time to
devote to MIDI projects.
Post by din5pin
Much of the below concerns VB, although there's C (+, ++, #) related
material as well. I didn't look over any of it in detail and can't vouch for
its value, but I hope some of it is helpful.
Post by din5pin
http://support.microsoft.com/kb/q181360/
http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/
http://www.codeguru.com/code/legacy/vb_multimedia/2138_midi.zip
http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/2138_faq.htm
Post by din5pin
http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1097/
http://www.codeguru.com/code/legacy/vb_multimedia/2041_BDcode.zip
http://www.lesliesanford.com/Programming/MIDIToolkit.shtml
http://www.lesliesanford.com/Programming/SourceFiles/MIDIToolkit.zip
http://home.modemss.brisnet.org.au/~mlevoi/midi.html
http://midishare.sourceforge.net/
http://www.harmony-central.com/MIDI/midivbx.zip
http://www.harmony-central.com/MIDI/midilib.zip
------------------------------------
Yahoo! Groups Links
rawl47
2010-01-20 16:38:15 UTC
Permalink
I too am mostly a lurker here although I do own a DX7 that I purchased new in 1986 as well as an Atari 800 I also purchased new along with lots of other vintage and modern music and computing hardware and software...

I am also a professional programmer having made a small fortune writing custom software for companies, non-profits, and government agencies large and small using just about any programming language that will do the job and let me deliver a reliable solution in a reasonable amount of time for a reasonable cost to my customer.

And that is the criteria. Will it do the job, can I deliver a solution that is reliable, can I do it in a reasonably quick fashion, and without costing the customer too much.

Some of my solutions were written in "wait for it"...

Visual Basic!

And for those who say that you can't do MIDI in VB, I guess you haven't ever made a Win API call from within VB. You should have read "The Visual Basic Programmer's Guide To The Windows API" by Dan Appleman.

Programming language bigots just don't get the point. These are tools. If you don't know how to use a tool but have another that will do the job, that's fine, as long as you get the job done. (See above "criteria"). But just because you don't know how to use a tool doesn't mean the tool is worthless. It means you lack knowledge and experience with that tool.

A customer once came to me with a project because of my extensive Oracle SQL database knowledge and experience building solutions where Oracle databases were used to house the data as the "backend". He wanted me to re-write his Cobol application to use Oracle to house all his data despite the fact that I had never written anything in Cobol. Did I tell him that Cobol was a dead language like the Latin of programming languages? No, I learned Cobol and rewrote all his I/O routines to store his data in an Oracle database and then added a bunch of web queries (also written in Cobol). Guess what, it works reliably and took far less time to put into production (including my Cobol learning time) than if I had started a rewrite from scratch in ANY OTHER language for the non Oracle "front-end" portion of the code.

Mechanics may have their favorite wrenches but at the end of the day, they all turn bolts.

Get over it. MIDI editors can be written in VB just like any other language. If you can't find code snippets from someone else to steal on how to do the MIDI I/O and that is what is stopping you then you need to learn how to truly program, not just cobble together other folks code.

VB will allow you to put together the graphical side of the program more rapidly than some of the other languages you might choose. There are other choices with that advantage as well.

To summarize this rant, there is nothing wrong with VB as a language. It is just another tool in the toolbag.

Rawl
Post by charlie from PARRY
thanks din5pin , alot of thuis code is like pascal and basic mixed together
,, is it VB code?
i never used vb at all
charles
Alan Probandt
2010-01-20 16:45:39 UTC
Permalink
Thanks for taking the time to post a message about VB. Great to get a correspondence from a professional programmer.

I will make another concerted effort to understand how to get MIDI data in and out of a Windows PC. Any success will be documented and posted in the files section here for further DX'ers to build on.
charlie from PARRY
2010-01-20 21:44:36 UTC
Permalink
somebody else allready posted links to site/pages explaining midi in and out
from the pc
in visual basic

no?

here is again


Much of the below concerns VB, although there's C (+, ++, #) related
material as
well. I didn't look over any of it in detail and can't vouch for its value,
but
I hope some of it is helpful.

http://support.microsoft.com/kb/q181360/

http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/
http://www.codeguru.com/code/legacy/vb_multimedia/2138_midi.zip
http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1095/2138_faq.htm

http://www.codeguru.com/vb/gen/vb_multimedia/article.php/c1097/
http://www.codeguru.com/code/legacy/vb_multimedia/2041_BDcode.zip

http://www.lesliesanford.com/Programming/MIDIToolkit.shtml
http://www.lesliesanford.com/Programming/SourceFiles/MIDIToolkit.zip

http://home.modemss.brisnet.org.au/~mlevoi/midi.html

http://midishare.sourceforge.net/

http://www.harmony-central.com/MIDI/midivbx.zip
http://www.harmony-central.com/MIDI/midilib.zip



charles


----- Original Message -----
From: "Alan Probandt" <***@yahoo.com>
To: <***@yahoogroups.com>
Sent: Wednesday, January 20, 2010 8:45 AM
Subject: [YamahaDX] Thanks for the message from a pro
Post by Alan Probandt
Thanks for taking the time to post a message about VB. Great to get a
correspondence from a professional programmer.
Post by Alan Probandt
I will make another concerted effort to understand how to get MIDI data in
and out of a Windows PC. Any success will be documented and posted in the
files section here for further DX'ers to build on.
Post by Alan Probandt
------------------------------------
Yahoo! Groups Links
Individual Email | Traditional
Dale (Inquisitor Betrayer)
2010-01-21 16:46:52 UTC
Permalink
well if you want to avoid some code
try this http://synthedit.com/ synthedit, you can put modules together like
toy blocks, does midi and even sysex.

I used it for effects and other things for years now. Even a simple
softsynth controller.
Used as a plug-in or stand alone.

If you want to make your own, you can too. Or buy others modules.

Dale

band web pages
Inquisitor Betrayer
"Space Elevator" Get it at http://cdbaby.com/cd/inquisitorbetrayer
http://www.inquisitorbetrayer.com ,
http://www.myspace.com/inquisitorbetrayer , http://www.PlanetOrigo.com and
iTunes
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?playListId=200365877

New group for Serious Musicians, ***@yahoogroups.com, for
those
who want to spend less time marketing and more time making music

Escuchen a los Inquisitor - Musica para Inteligentes.
Music is nothing if the audience is deaf.

----- Original Message -----
Post by charlie from PARRY
somebody else allready posted links to site/pages explaining midi in and out
from the pc
in visual basic
no?
w***@purplehorses.nl
2010-01-19 15:35:17 UTC
Permalink
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>







<body style="background-color: #fff;">
<span style="display:none">&nbsp;</span>

<!--~-|**|PrettyHtmlStartT|**|-~-->
<div id="ygrp-mlmsg" style="position:relative;">
<div id="ygrp-msg" style="z-index: 1;">
<!--~-|**|PrettyHtmlEndT|**|-~-->

<div id="ygrp-text" >


<p><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



Guys,<br>
<br>
What about the .net languages like vb.net/C#?C&#43;<wbr>+/F# or Java?<br>
<br>
Marco<br>
<br>
Alan Probandt schreef:
<blockquote cite="mid:***@web52606.mail.re2.yahoo.com" type="cite"><span>&nbsp;</span>

<div id="ygrp-text">
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font-family: inherit;font-style: inherit;font-variant: inherit;font-weight: inherit;font-size: inherit;font-size-adjust: inherit;font-stretch: inherit;" valign="top">Visual Basic ver 6 from 1998 has well-documented support
for the serial COM port.&nbsp; It's not really easy to work with, but it
does work.&nbsp; However it only works at standard baud rates like 9600,
19200, and 38400 baud.&nbsp;&nbsp; If you have a 1990s era Yamaha with a
'to-host' interface, then you can use the serial port to communicate
with the tone module using a serial port with VB6.<br>
&nbsp; <br>
&nbsp; The Windows MIDI port is never directly interfaced with by a standard
compiler like Visual Basic or Visual C.&nbsp; The user loads a direct-link-<wbr>library
(DLL) that acts as a bridge between the compiler and whatever MIDI port
is available on the Windows PC.&nbsp; To receive a MIDI sysex dump from a
TX81Z, the user would reserve a block of memory (a buffer) for the
sysex data, create another buffer that holds the sysex request string,
and somehow instruct the Multi-Media DLL to output the bytes from one
buffer and save the incoming bytes.&nbsp; But this is all completely
undocumented, nor have I ever seen a working piece of code that shows
how to do it.&nbsp; But it can be done because there are Windows editor
programs. <br>
&nbsp; I have emailed the various programmers many times how they do this.&nbsp;
I either get no response or maybe an undocumented cryptic block of C&#43;+
code, which may or may not have anything to do with MIDI interfacing.&nbsp;
The only documentation that the pinheads at Microsoft will release
about MIDI is how to play a MIDI file using DLLs.&nbsp; Linux works
more-or-less the same way, if I understand correctly, which I don't.&nbsp;
The Mac people don't understand why any user would want to do anything
with code when it is just such easier to simply pay $600 for an
'insanely great' program that does it for you so much better than
'Windows junk' ever could.&nbsp; The idea that some people can't drop $600
on a simple program is beyond the comprehension of the people who use
Macs.<br>
<br>
&nbsp; With 1990s DOS and an MPU401 MIDI card, you would read/write directly
to a pair of Input/Output ports.&nbsp; Each port had a status register.&nbsp; If
a bit in the status register was set, then you could write a byte to
the output port and it would zoom out the MIDI card to the synth.&nbsp; If a
different bit in the status reg was set, then the synth sent you a MIDI
byte. Better read it quickly before the next one arrived. To get a
sysex dump, just read bytes until the value 0xF7 arrived.<br>
<br>
&nbsp; With a stand-alone microcontroller like a PIC or an AVR Aurdino you
have a programmable UART, which is a serial port.&nbsp; There is a formula
to get the UART to send and receive data at 31250 baud that depends on
the controller's system clock speed.&nbsp; The clock speed is usually slow
like 8 megahertz.&nbsp; Then the UART acts like the MPU401 card. Often there
is a memory size limit in the microcontroller.&nbsp; For instance, the AVR
Mega88 IC used in the Aurdino has only 1024 bytes of RAM.&nbsp; This
prevents it from receiving and storing large sysex dumps from the
synth, such as whole banks of voices. <br>
<br>
&nbsp;Microcontroller boards usually have small LCD character displays, 16
chars by 2 rows is common. These are inexpensive ($3-$8) and have
easy-to-use standard interfaces.&nbsp; Graphic LCDs of 128 pixels by 64
pixels are about $20 and are more difficult to program. PC standard PS2
QWERTY keyboards are easy to interface to microcontrollers and a mouse
is less easy, but not too difficult. Now almost all microcontrollers
have built-in analog-to-digital converters so it is easy to add
potentiometers (knobs), encoders (knobs that spin endlessly) and
sensors.&nbsp; MIcrocontroller chips cost between $1 and $5, but they will
need a programmer and development/<wbr>debug system that is usually
about $100.&nbsp; AVRs can be programmed directly from the PC parallel port
with inexpensive (@$10) interfaces or the USB on the PC (a $20
interface).&nbsp; The development/<wbr>debug programming tools, assemblers,
C compilers, and datasheet documentation is all freely available from
the manufacturers' websites.&nbsp; The chips themselves are available from
DigiKey (a major US parts distributor) or from eBay auctions in small
quantities.&nbsp; Writing and debugging MIDI programs on them can be very
time consuming, but it might lead to a new career as an
embedded-systems developer.</td>
</tr>
</tbody>
</table>
<br>
</p>
</div>


<!-- end group email --></blockquote>
<br>


</p>

</div>


<!--~-|**|PrettyHtmlStart|**|-~-->
<div style="color: #fff; height: 0;">__._,_.___</div>




<div id="ygrp-actbar" style="clear: both; margin-bottom: 10px; white-space: nowrap; color: #666; padding-top: 15px;">
<div>
<a href="mailto:***@purplehorses.nl?subject=Re: [YamahaDX] Visual Basic to work with existing sysex files">
Reply to <span style="font-weight: 700;">sender</span></a>
| <a href="mailto:***@yahoogroups.com?subject=Re: [YamahaDX] Visual Basic to work with existing sysex files">
Reply to <span style="font-weight: 700;">group</span></a>
</div>

<a href="http://groups.yahoo.com/group/YamahaDX/message/9652;_ylc=X3oDMTMzMG9taWJzBF9TAzk3MzU5NzE0BGdycElkAzI4MDg3OQRncnBzcElkAzE3MDUwMzIxNDQEbXNnSWQDOTY3NARzZWMDZnRyBHNsawN2dHBjBHN0aW1lAzEyNjM5MTUzNDYEdHBjSWQDOTY1Mg--">Messages in this topic</a>
(<span style="font-weight: 700;">22</span>)
</div>
<!------- Start Nav Bar ------>

<!-- |**|begin egp html banner|**| -->
<div id="ygrp-vital" style="background-color: #e0ecee; font-family: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">
<span id="vithd" style="font-weight: bold; color: #333; text-transform: uppercase; ">Recent Activity:</span>

<ul style="list-style-type: none; margin: 0; padding: 0; display: inline;">
<li style="border-right: 1px solid #000; font-weight: 700; display: inline; padding: 0 5px; margin-left: 0;">
<span class="cat"><a href="http://groups.yahoo.com/group/YamahaDX/members;_ylc=X3oDMTJldnR0aXFjBF9TAzk3MzU5NzE0BGdycElkAzI4MDg3OQRncnBzcElkAzE3MDUwMzIxNDQEc2VjA3Z0bARzbGsDdm1icnMEc3RpbWUDMTI2MzkxNTM0Ng--?o=6" style="text-decoration: none;">New Members</a></span>
<span class="ct" style="color: #ff7900;">4</span>
</li>
</ul>

<div style="clear: both; padding-top: 2px; color: #1e66ae;">
<a href="http://groups.yahoo.com/group/YamahaDX;_ylc=X3oDMTJkMXNkaHZzBF9TAzk3MzU5NzE0BGdycElkAzI4MDg3OQRncnBzcElkAzE3MDUwMzIxNDQEc2VjA3Z0bARzbGsDdmdocARzdGltZQMxMjYzOTE1MzQ2" style="border-right: 1px solid #000; padding-right: 5px; margin-right: 2px; text-decoration: none;">Visit Your Group</a>
<a href="http://groups.yahoo.com/group/YamahaDX/post;_ylc=X3oDMTJkZGpuZGdhBF9TAzk3MzU5NzE0BGdycElkAzI4MDg3OQRncnBzcElkAzE3MDUwMzIxNDQEc2VjA2Z0cgRzbGsDbnRwYwRzdGltZQMxMjYzOTE1MzQ2" style="font-weight: 700; text-decoration: none;">Start a New Topic</a>
</div>
</div>

<div id="ygrp-mkp" style="border: 1px solid #d8d8d8; clear: both; float: left; font-family: Arial; margin: 5px 0 10px 0; padding: 0 10px;">
<div id="hd" style="color: #628c2a; font-size: 85%; font-weight: 700; line-height: 122%; margin: 10px 0;">MARKETPLACE</div>
<div id="ads" style="margin-bottom: 10px;">
<div class="ad" style="color: #628C2A; font-family: Arial; font-weight: 700; padding: 0 0;">
<p><a href="http://us.ard.yahoo.com/SIG=14kohnqd7/M=493064.13814333.13821539.13298430/D=grplch/S=1705032144:MKP1/Y=YAHOO/EXP=1263922546/L=/B=iQlBI0PDhEk-/J=1263915346472967/K=ZB0pGDGkHRiGctmglIBp5w/A=5922843/R=0/SIG=11ckn2mo6/*http://advision.webevents.yahoo.com/green/">Going Green: Your Yahoo! Groups resource for green living</a></p> </div>
</div>
</div>

<div id="ft" style="font-family: Arial; font-size: 11px; margin-top: 5px; padding: 0 2px 0 0; clear: both;">
<a href="http://groups.yahoo.com/;_ylc=X3oDMTJjNGtjZTB1BF9TAzk3NDc2NTkwBGdycElkAzI4MDg3OQRncnBzcElkAzE3MDUwMzIxNDQEc2VjA2Z0cgRzbGsDZ2ZwBHN0aW1lAzEyNjM5MTUzNDY-" style="float: left;"><img src="Loading Image..." height="15" width="137" alt="Yahoo! Groups" style="border: 0;"/></a>
<div style="color: #747575; float: right;">Switch to: <a href="mailto:YamahaDX-***@yahoogroups.com?subject=Change Delivery Format: Traditional" style="text-decoration: none;">Text-Only</a>, <a href="mailto:YamahaDX-***@yahoogroups.com?subject=Email Delivery: Digest" class="margin-rt" style="text-decoration: none;">Daily Digest</a> &bull; <a href="mailto:YamahaDX-***@yahoogroups.com?subject=Unsubscribe" style="text-decoration: none;">Unsubscribe</a> &bull; <a href="http://docs.yahoo.com/info/terms/" style="text-decoration: none;">Terms of Use</a></div>
</div>

<!-- |**|end egp html banner|**| -->

</div> <!-- ygrp-msg -->

<!-- Sponsor -->
<!-- |**|begin egp html banner|**| -->
<div id="ygrp-sponsor" style="width:160px; float:right; clear:none; margin:0 0 25px 0; background: #fff;">

<!-- Start Recommendations -->
<div id="ygrp-reco">
</div>
<!-- End Recommendations -->



</div> <!-- |**|end egp html banner|**| -->

<div style="clear:both; color: #FFF; font-size:1px;">.</div>
</div>

<img src="http://geo.yahoo.com/serv?s=97359714/grpId=280879/grpspId=1705032144/msgId=9674/stime=1263915346/nc1=3848621/nc2=3848643/nc3=4025321" width="1" height="1"> <br>

<div style="color: #fff; height: 0;">__,_._,___</div>
<!--~-|**|PrettyHtmlEnd|**|-~-->

</body>

<!--~-|**|PrettyHtmlStart|**|-~-->
<head>
<style type="text/css">
<!--
#ygrp-mkp {
border: 1px solid #d8d8d8;
font-family: Arial;
margin: 10px 0;
padding: 0 10px;
}

#ygrp-mkp hr {
border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
color: #628c2a;
font-size: 85%;
font-weight: 700;
line-height: 122%;
margin: 10px 0;
}

#ygrp-mkp #ads {
margin-bottom: 10px;
}

#ygrp-mkp .ad {
padding: 0 0;
}

#ygrp-mkp .ad a {
color: #0000ff;
text-decoration: none;
}
#ygrp-sponsor #ygrp-lc {
font-family: Arial;
}

#ygrp-sponsor #ygrp-lc #hd {
margin: 10px 0px;
font-weight: 700;
font-size: 78%;
line-height: 122%;
}

#ygrp-sponsor #ygrp-lc .ad {
margin-bottom: 10px;
padding: 0 0;
}

a {
color: #1e66ae;
}

#actions {
font-family: Verdana;
font-size: 11px;
padding: 10px 0;
}

#activity {
background-color: #e0ecee;
float: left;
font-family: Verdana;
font-size: 10px;
padding: 10px;
}

#activity span {
font-weight: 700;
}

#activity span:first-child {
text-transform: uppercase;
}

#activity span a {
color: #5085b6;
text-decoration: none;
}

#activity span span {
color: #ff7900;
}

#activity span .underline {
text-decoration: underline;
}

.attach {
clear: both;
display: table;
font-family: Arial;
font-size: 12px;
padding: 10px 0;
width: 400px;
}

.attach div a {
text-decoration: none;
}

.attach img {
border: none;
padding-right: 5px;
}

.attach label {
display: block;
margin-bottom: 5px;
}

.attach label a {
text-decoration: none;
}

blockquote {
margin: 0 0 0 4px;
}

.bold {
font-family: Arial;
font-size: 13px;
font-weight: 700;
}

.bold a {
text-decoration: none;
}

dd.last p a {
font-family: Verdana;
font-weight: 700;
}

dd.last p span {
margin-right: 10px;
font-family: Verdana;
font-weight: 700;
}

dd.last p span.yshortcuts {
margin-right: 0;
}

div.attach-table div div a {
text-decoration: none;
}

div.attach-table {
width: 400px;
}

div.file-title a, div.file-title a:active, div.file-title a:hover, div.file-title a:visited {
text-decoration: none;
}

div.photo-title a, div.photo-title a:active, div.photo-title a:hover, div.photo-title a:visited {
text-decoration: none;
}

div#ygrp-mlmsg #ygrp-msg p a span.yshortcuts {
font-family: Verdana;
font-size: 10px;
font-weight: normal;
}

.green {
color: #628c2a;
}

.MsoNormal {
margin: 0 0 0 0;
}

o {
font-size: 0;
}

#photos div {
float: left;
width: 72px;
}

#photos div div {
border: 1px solid #666666;
height: 62px;
overflow: hidden;
width: 62px;
}

#photos div label {
color: #666666;
font-size: 10px;
overflow: hidden;
text-align: center;
white-space: nowrap;
width: 64px;
}

#reco-category {
font-size: 77%;
}

#reco-desc {
font-size: 77%;
}

.replbq {
margin: 4px;
}

#ygrp-actbar div a:first-child {
/* border-right: 0px solid #000;*/
margin-right: 2px;
padding-right: 5px;
}

#ygrp-mlmsg {
font-size: 13px;
font-family: Arial, helvetica,clean, sans-serif;
*font-size: small;
*font: x-small;
}

#ygrp-mlmsg table {
font-size: inherit;
font: 100%;
}

#ygrp-mlmsg select, input, textarea {
font: 99% Arial, Helvetica, clean, sans-serif;
}

#ygrp-mlmsg pre, code {
font:115% monospace;
*font-size:100%;
}

#ygrp-mlmsg * {
line-height: 1.22em;
}

#ygrp-mlmsg #logo {
padding-bottom: 10px;
}

#ygrp-mlmsg a {
color: #1E66AE;
}

#ygrp-msg p a {
font-family: Verdana;
}

#ygrp-msg p#attach-count span {
color: #1E66AE;
font-weight: 700;
}

#ygrp-reco #reco-head {
color: #ff7900;
font-weight: 700;
}

#ygrp-reco {
margin-bottom: 20px;
padding: 0px;
}

#ygrp-sponsor #ov li a {
font-size: 130%;
text-decoration: none;
}

#ygrp-sponsor #ov li {
font-size: 77%;
list-style-type: square;
padding: 6px 0;
}

#ygrp-sponsor #ov ul {
margin: 0;
padding: 0 0 0 8px;
}

#ygrp-text {
font-family: Georgia;
}

#ygrp-text p {
margin: 0 0 1em 0;
}

#ygrp-text tt {
font-size: 120%;
}

#ygrp-vital ul li:last-child {
border-right: none !important;
}
-->
</style>
</head>

<!--~-|**|PrettyHtmlEnd|**|-~-->
</html>
<!-- end group email -->
Lee Borrell
2010-01-13 14:47:04 UTC
Permalink
Thanks for that.

--- On Mon, 11/1/10, Alan Probandt <***@yahoo.com> wrote:


From: Alan Probandt <***@yahoo.com>
Subject: [YamahaDX] Visual Basic to work with existing sysex files
To: ***@yahoogroups.com
Date: Monday, 11 January, 2010, 15:50


 







Yes, You're right about appreciating technology that works 95% of the time.  We could be all using Soviet microprocessors: every one came with a customized list of the instructions that didn't work on the individual chip.

  And yes the voices that I have been previewing are from the web file of sysex banks found at xy.cx/synth/ tg77.  I have no idea how to send and receive MIDI data using Microsoft Windows APIs.   One would think that Roland, Korg, and Yamaha would at least ask Microsoft to make it just a little bit easier to program the MIDI info that their Electronic Music Instrument divisions depend on.

  Below is the VB procedures for working with these SY/TG77 bank files.  The window display is just a few buttons and text boxes.  The split button breaks the bank file into 64 voice files in a new folder.  The renumber button lets you change the byte and checksum that determines which of the 64 voice locations gets the data.  The new files aren't sent to the TG77; MIDI-OX does that.

'Yamaha SY77/TG77 tone module voice bank mini-librarian program

'Variables are global because this is tiny and specialized program.
'Also allows all loaded data arrays to be used by different button routines.

' byte variables and array definitions
Dim VoiceBytes(1600) As Byte, ReNumVoiceBytes( 1600) As Byte
Dim databyte As Byte, VoiceChar As Byte, bNewNumber As Byte
Dim bVoiceCount As Byte, bCheckSum As Byte, bOriginalCkSum As Byte
' integer variables and array definitions
Dim i As Integer, j As Integer, iVoiceSysExFile As Integer
Dim iThisVoicesByteCoun t As Integer, iPointer As Integer
Dim iBigSysExFile As Integer, iLittleSysExFile As Integer, iReNumVoiceSysExFil e As Integer
Dim iReNumVoiceByteCoun t As Integer
' string variables and array definitions
Dim ThisVoicesName As String, LittleFileName As String
Dim VoiceNames(64) As String, NewNumStr As String
Dim LastCharInName As String, HexSumStr As String
Dim ListFileName As String, aDirName As String
Dim Name_NumStr As String, NameStr As String ' used in btnRenum and btnDoRenum
Dim iName_NumPos As Integer
Dim NewNumFileNameStr As String
' other variable definitions
Dim lOffsetFromBeginnin g As Long, lDataSum As Long


Private Sub Form_Load()
    btnDoRenum.Visible = False
End Sub


' Click here to renumber a single voice.  The SY77/TG77 voice number (the voice's position
' in the I-bank) is fixed in the sysex data and checksum, so you can't just change it and
' load the data.  The checksum must also be recalculated.  This procedure calls the File:Open
' loads the voice data from the selected single-voice file into an array.  The user should enter
' a new number (1-64) into the New_Number textbox and click on the ReNum button.
Private Sub btnRenum_Click( )
    btnSplit.Visible = False
   
    CommonDialog1. ShowOpen ' select and load a voice file
    If CommonDialog1. FileName = "" Then Exit Sub
    iReNumVoiceSysExFil e = FreeFile
    Open CommonDialog1. FileName For Binary Access Read As #iReNumVoiceSysExFi le
   
    NewNumFileNameStr = CommonDialog1. FileName ' full path name
    iName_NumPos = InStrRev(NewNumFile NameStr, "\")
    Name_NumStr = Right$(NewNumFileNa meStr, Len(NewNumFileNameS tr) - iName_NumPos) ' remove path
    NameStr = Right$(Name_ NumStr, Len(Name_NumStr) - 3) ' remove file extension
    btnDoRenum.Visible = True

    iReNumVoiceByteCoun t = 0
    Do ' load all the bytes for this individual voice into an array
        Get #iReNumVoiceSysExFi le, , databyte
        ReNumVoiceBytes( iReNumVoiceByteC ount) = databyte
        iReNumVoiceByteCoun t = iReNumVoiceByteCoun t + 1
    Loop Until databyte = &HF7
   
    txtOrgNumber. Text = CStr(ReNumVoiceByte s(&H1F)) + 1
    Close iReNumVoiceSysExFil e
   
End Sub

' Second half of voice-renumbering. Receive NameStr and ReNumVoiceBytes( ) from btnReNum_Click( ).

' When a voice with original number 49 or greater is renumbered to less than 49,
' a checksum error happens when the renumbered file is loaded into the TG77, even though the checksum is correct.

Private Sub btnDoRenum_Click( )
    If txtNewNum.Text = "" Then
        MsgBox ("New Voice Number textbox is blank. Enter 1-64")
        Exit Sub
    End If
    bNewNumber = (CByte(txtNewNum. Text)) - 1
    ReNumVoiceBytes(&H1F) = bNewNumber ' put new I-bank location into sysex array
   
    ' calculate CheckSum for the sysex block with new I-bank location
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + ReNumVoiceBytes( iPointer)
        iPointer = iPointer + 1
    Loop Until iPointer = iReNumVoiceByteCoun t - 2
    bCheckSum = CByte(lDataSum And &H7F) ' step-by-step verification of the new checksum
    bCS1 = Not bCheckSum
    bCS1a = bCS1 And 127
    BCS2 = bCS1a + 1
    bCS3 = BCS2 And 127
    ReNumVoiceBytes( iReNumVoiceByteC ount - 2) = bCS3  ' update the checksum value in the sysex block
   
    NewNumStr = CStr(bNewNumber + 1)
    ' put new location number at beginning of the file name for the sysex block
    If Len(NewNumStr) = 1 Then NewNumStr = "0" & NewNumStr ' leading zero if needed
    NewNumFileNameStr = NewNumStr & "_" & NameStr
    Open NewNumFileNameStr For Binary Access Write As #iReNumVoiceSysExFi le
    For i = 0 To iReNumVoiceByteCoun t - 1
        Put #iReNumVoiceSysExFi le, , ReNumVoiceBytes( i)
    Next i
    Close iReNumVoiceSysExFil e
    txtOrgNumber. Text = " "
    txtNewNum.Text = " "
    btnSplit.Visible = True
    btnDoRenum.Visible = False
End Sub


' expand a (64-voice) bank sysex-file into a new folder that holds 64 individual voice sysex files, and a text file with the voice names.
Private Sub btnSplit_Click( )
' general initialization of global variables used by the button-click procedure
bVoiceCount = 0
iThisVoicesByteCoun t = 0
lOffsetFromBeginnin g = 0
LastCharInName = ""

' select and open sysex bank file (that holds 64 voices)
btnDoRenum.Visible = False
CommonDialog1. ShowOpen
If CommonDialog1. FileName = "" Then Exit Sub
iBigSysExFile = FreeFile
Open CommonDialog1. FileName For Binary Access Read As #iBigSysExFile
aDirName = CommonDialog1. FileName
aDirName = Left$(aDirName, Len(aDirName) - 4)
MkDir (aDirName)
ChDir (aDirName)

Do ' on each of the 64 voices in the sysex bank file
    ThisVoicesName = ""
    iThisVoicesByteCoun t = 0
   
    Do ' load all the bytes for this individual voice into an array
        Get #iBigSysExFile, , databyte
        VoiceBytes(iThisVoi cesByteCount) = databyte
        iThisVoicesByteCoun t = iThisVoicesByteCoun t + 1
        lOffsetFromBeginnin g = lOffsetFromBeginnin g + 1
    Loop Until databyte = &HF7

    For i = &H21 To &H2A ' load the voice name chars into a string
        VoiceChar = VoiceBytes(i)
        ThisVoicesName = ThisVoicesName & Chr(VoiceChar)
    Next i
   
    ThisVoicesName = Trim$(ThisVoicesNam e)
    ' convert invalid filename characters to underscore
   
    For i = 1 To Len(ThisVoicesName)
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H30 Or (Asc(Mid$(ThisVoice sName, i, 1))) > &H7A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H41 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H39 Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
        If (Asc(Mid$(ThisVoice sName, i, 1))) < &H61 And (Asc(Mid$(ThisVoice sName, i, 1))) > &H5A Then
            Mid$(ThisVoicesName , i, 1) = Chr(&H5F)
        End If
    Next i   ' convert invalid filename chars for loop
   
    ' add this voice's name to the list of all the voice names found in the bank file
    VoiceNames(bVoiceCo unt) = ThisVoicesName
  
    ' make a little sysex file (between 200 - 1600 bytes) of this voice's parameter values
    iLittleSysExFile = FreeFile
    LittleFileName = CStr(bVoiceCount + 1) & "_" & ThisVoicesName & ".syx"
    If bVoiceCount < 9 Then LittleFileName = "0" & LittleFileName
    Open LittleFileName For Binary Access Write As #iLittleSysExFile
    For i = 0 To iThisVoicesByteCoun t - 1
        Put #iLittleSysExFile, , VoiceBytes(i)
    Next i
    Close iLittleSysExFile
    bVoiceCount = bVoiceCount + 1

    bOriginalCkSum = VoiceBytes(iThisVoi cesByteCount - 2)
    txtOrgNumber. Text = CStr(VoiceBytes(&H1F))
   
    ' calculate CheckSum and compare to original checksum in file
    lDataSum = 0
    iPointer = &H6
    Do
        lDataSum = lDataSum + VoiceBytes(iPointer )
        iPointer = iPointer + 1
    Loop Until iPointer = iThisVoicesByteCoun t - 2
    bCheckSum = lDataSum And &H7F
    bCheckSum = ((Not (bCheckSum)) + 1) And &H7F
    If bOriginalCkSum <> bCheckSum Then MsgBox ("Original and calculated checksums don't match")
   
Loop Until bVoiceCount = 64  ' end of processing on the individual voice

Close iBigSysExFile
iVoiceListFile = FreeFile

' make a text file of all the voice names in the sysex bank file
' this file is placed in the same folder as the sysex bank file
ListFileName = Left$(CommonDialog1 .FileName, Len(CommonDialog1. FileName) - 4)
ListFileName = ListFileName + ".txt" ' re-use the bank file name, but change the file extension to .txt
Open ListFileName For Output As #iVoiceListFile
For i = 0 To 15
    Print #iVoiceListFile, i + 1; " "; VoiceNames(i) ; Tab(20); i + 17; " "; VoiceNames(i + 16); Tab(40); i + 33; " "; VoiceNames(i + 32); Tab(60); i + 49; " "; VoiceNames(i + 48)
Next i

Close iVoiceListFile

End Sub

Private Sub btnEnd_Click( )
    End
End Sub
Loading...