Questions about the MIDI code of Shruthi-1

OK, I have decided to take the bull by the horns, and make a personal firmware for the Shruthi-1 that will allow me to fix the incompatibility with the checksum in SoundDiver which I use as an editor for it.

SoundDiver allows for a nibbelized checksum that goes LH, which is opposite of Shruthi’s HL checksum, so I thought it might be best to simply change the firmware, so that it simply swap the transmitted and recieved checksum nibbles.

I’ve set up the toolchain, and I can now compile .hex/.syx/.mid firmware files, so the only thing missing is changing the code itself in the firmware.

But to be honest, this C (or C+/++ whatever) is totaly new to me, having only worked with PIC assembly code, so I’ve been fooling around with the Shruthi code, to see if I can find and decipher the correct code to change, and would like to know if I’m going in the right direction.

In the code file “storage.cc” I’ve found what I believe to be the code to change (?)… in two places… and they are as follows for sending sysex dumps:

@
/* static */
void Storage::SysExDumpBuffer(
uint8_t* data,
uint8_t command,
uint8_t argument,
uint8_t size) {
Serial<MidiPort, 31250, DISABLED, POLLED> midi_output;
// Outputs the SysEx header.
for (uint8_t i = 0; i < sizeof(sysex_rx_header); ++i) {
midi_output.Write(pgm_read_byte(sysex_rx_header + i));
}
midi_output.Write(command);
midi_output.Write(argument);

uint8_t checksum = 0;
for (uint8_t i = 0; i < size; ++i) {
checksum += data[i];
midi_output.Write(U8ShiftRight4(data[i]));
midi_output.Write(data[i] & 0x0f);
}

  • midi_output.Write(U8ShiftRight4(checksum));
  • midi_output.Write(checksum & 0x0f);

midi_output.Write(0xf7); //
}
@

Now, I asume that to swap the two nibbles being send out as checksum in a sysex dump, that the two lines that I’ve marked with an * has to be swapped in possition?

And now the recieving part:

@ case RECEIVING_DATA:
{
uint16_t i = sysex_rx_bytes_received_ >> 1;
if (sysex_rx_bytes_received_ & 1) {

  • sysex_rx_destination_[i] |= sysex_rx_byte & 0xf;
    if (i < sysex_rx_expected_size_) {
    sysex_rx_checksum_ += sysex_rx_destination_[i];
    }
    } else {
  • sysex_rx_destination_[i] = U8ShiftLeft4(sysex_rx_byte);
    }
    sysex_rx_bytes_received_**;
    if (sysex_rx_bytes_received_ >= (1 + sysex_rx_expected_size_) * 2) {
    sysex_rx_state_ = RECEIVING_FOOTER;
    }
    }
    break;@

I suppose that here, the two lines marked with * is the ones to swap?

I hope that you (Pichenettes) can confirm this, or at least guide me in the right direction if I’m wrong?

Regards.

Sorry for the messy way the code is shown… I just copied the text from notepad, and the forum obviously prints it like this.

Try putting the code in ätSigns s:

@
void Storage::SysExDumpBuffer( uint8_t* data, uint8_t command, uint8_t argument, uint8_t size) { Serial<MidiPort, 31250, DISABLED, POLLED> midi_output; // Outputs the SysEx header. for (uint8_t i = 0; i < sizeof(sysex_rx_header); +i) { midi_output.Write(pgm_read_byte(sysex_rx_header i)); } midi_output.Write(command); midi_output.Write(argument);
uint8_t checksum = 0; for (uint8_t i = 0; i < size; +i) { checksum= data[i]; midi_output.Write(U8ShiftRight4(data[i])); midi_output.Write(data[i] & 0x0f); }
midi_output.Write(U8ShiftRight4(checksum));
midi_output.Write(checksum & 0x0f);
midi_output.Write(0xf7); // }@

Edit - OK, doesn’t make it better…

hmm… seems to work for the lower code snippet, but not the top one… but thanks for the tip :slight_smile:

Yes, looks like the changes you recommend will do the trick.

Thanks! … I’ll have a go at it then :slight_smile:

@razmo Ahh, Sounddiver - another reason to boycott Apple products after they killed off this fine programme.

@Fitvideo good point. There’s only one commercial alternative still available, MIDIQuest, and that’s hideously overpriced, and looking seriously long in the tooth these days. I guess Ctrlr is the way to go, but the list of device panels on the official website isn’t exactly comprehensive. I’m tempted to roll up my sleeves and create panels for all my gear, but I just know that’s going to be a whole can of worms, and I’ll probably become obsessed with making the panels look nice, get discouraged when they (inevitably) don’t, and give up half way through. Judging by what widy has said about his Shruthi-1 panel, the process of creating one doesn’t seem especially easy (or well-documented), either…

a|x

@toneburst
I was pissed when Apple did that … still am.
TubeOhm is about to release a Shruthi controller in two flavours VST and Standalone for the PC, with what he calls a stepper (16 note cc change sequencer) and effects. I have been assisting along with another guy in beta testing it. It is not far off.
Video tutorials in German and English and a manual to follow as well.
Shruthi Editor
regards

CTRLR is not for me… it’s only based on NRPN or CC in the general user editing… the good thing about SoudDiver is that anyone with a bit of MIDI understanding can make their own adaptions, and I’ve been making A LOT of these over the years. Unfortunately the “hardwired” possibilities of sounddivers adaption editing also means that it is sometimes incompatible with newer (or weird) ways of handling SysEx.

My major problem with Shruthi-1 and SoundDiver was that the checksum format was not supported, and that basicaly renders SoundDiver useless… but I managed to make a special firmware that simply disable the checksum in Shruthi-1, and it works fine… I can now do the following:

Request all patches into 4 banks (cannot be written back to shruthi due to entry number incompatibility with Shruthi’s write patch sysex command)

Request/send the current sequence (can not be requested into a bank because the shruthi combo function does not read sequences as it recieves program changes, it only work from the panel unfortunately)

Sequences can be edited in editor

Transmit a full user wavetable with all 8 waveforms.

Edit/copy/paste single wavetable waveforms around, and save them individualy or as a full wavetable into a library.

Combo feature… a data type that combines patch, sequence, wavetable and global parameters into a single large combined “patch”… this allows for sequences and wavetables to be an integral part of a patch which really is nice when using user wavtables and sequences tailored to the patch… these can be saved in libraries and browsed simply by clickig on them. This was one of my main goals with this editor.

I know MIDI Quest, and I do not like it… it’s too complicated to do your own adaptions, and it crashes even more than SoundDiver does.

SoundDiver is still the ONLY one of two universal editor programs out there that allows you to have all your synths edited from a single program, and that’s why I still use it… I have it constantly running in the background when I make music, so that I can have unlimited patches (using libraries) and quick editing functionality.

But yes… unfortunately Apple destroyed this app along with logic for windows… also the turn to VSTs instead of real hardware had it’s impact on these kind of programes, which is really a pitty.

Today it’s impossible to buy SoundDiver anymore, so if you want to use it, you’d have to walk the dark road of piracy to get it… even though, it’s hard to find even that way these days… they really should make this app open source that someone out there with the skill could develop it further… but with Apple holding the rights? … won’t happen…