Jump to content

a tiny midi-processor


avogra

Recommended Posts

Hey everyone!

after half a year lurking around ucapps and the forum, i finally ordered a bare core from mike's and got into things :) I didn't believe that anything would work the first time. but - praise to great tutorials for a great platform! - voltages where correct, nothing smelled suspiciously when trying with the pic plugged in, and when looking carefully, i even noticed the stiffed in led flickering a little :) i wasn't prepared to be so happy about a led :)

when i arrived at my pc (200km away -.-) with already set-up toolchain, the next moment of excitement was waiting for me: will it talk to me??? and jepp, it did periodically :) uploading mios was just a hop. so its coding time for my first c-app!

what i'm after: main intention is a velocity converter to take care of the odd velocity-curve of my yamaha P80. next issue is teaching my floorboard to talk sysex. up to now, thats all i need. although a 3-port merger would be nice, and maybe some knobs n buttons to supplement or even replace the floorboard, and... hm i'm not even lightly scratching the possibilities of mios, d'oh!

but better get into things step-by-step, so back to the velocity converter, which really gave me headaches. it should be really simple, but as my even little C-skills are quite rusted, it took me 3 hours to figure out how to implement a basic translation-table. at least it works now :) lets see how i will cope with the sysex stuff :-P

so far, many many thanks to Thorsten and everyone else for the fun, that mbhp and mios have already given to me! awesome work!!

cu, Alex

Link to comment
Share on other sites

Congrats on getting well started.

Since I usually do asm instead of C, I may be giving bad advice, but I was faced with a similar challenge in converting from linear to log and back again.

I eventually used Excel to calculate (and graph) the desired curve, then I abused it into writing the asm source code for me. It was a bit ugly up front, but I now have the easy means to alter the curve and re-generate the needed source code.

If that sounds interesting to you, you will find the spreadsheet in this zip file:

http://www.midibox.org/dokuwiki/lib/exe/fetch.php?media=pga:logcurve.zip

It makes a nice bridge from the easy office spreadsheet to the source code.

In any case, have fun!

LyleHaze

Link to comment
Share on other sites

Thanks for the welcome :)

@lylehaze: thnx for the hint. i did something similar in *cough* basic, that generates a file, ready for copy n paste.

right now, im somewhat stuck in ashaming (?) C-Basics :(

The velocity translation works perfect. What i did next, is a very basic sysex-parser. but i don't get it to compile. seems to have to do with my includes: the function sysex_parse() is in the file midi_process.c, functions are declared in midi_process.h . the .h-file is included in the main.c

when i also #include midi_process.c , it compiles fine.

Someone have a look? I stripped the code down to the basics and moved the function call into Init(void) for shortness, so don't be puzzeled, what's its purpose there :) also attached complete files in test.rar

Console output first:

CD: C:\Eigene Dateien\MIOS\test\
Current directory: C:\Eigene Dateien\MIOS\test
make
Process started >>>
rm -rf _output/*
rm -rf _output
rm -rf *.cod *.map *.lst
rm -rf *.hex
mkdir -p _output
sh C:\Programme\MIOS_base\bin/mios-gpasm -c -p p18f452 -I./src -I C:\Programme\MIOS_base/include/asm -I C:\Programme\MIOS_base/include/share -I C:\Programme\MIOS_base/modules/app_lcd/dummy -DDEBUG_MODE=0  -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I C:\Programme\MIOS_base/modules/mios_wrapper C:\Programme\MIOS_base/modules/mios_wrapper/mios_wrapper.asm  -o _output/mios_wrapper.o
sh C:\Programme\MIOS_base\bin/mios-gpasm -c -p p18f452 -I./src -I C:\Programme\MIOS_base/include/asm -I C:\Programme\MIOS_base/include/share -I C:\Programme\MIOS_base/modules/app_lcd/dummy -DDEBUG_MODE=0   C:\Programme\MIOS_base/modules/app_lcd/dummy/app_lcd.asm -o _output/app_lcd.o
sh C:\Programme\MIOS_base\bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2  -I./src -I C:\Programme\MIOS_base/include/c -I C:\Programme\MIOS_base/include/share -DDEBUG_MODE=0  main.c -o _output/main.o
C:\Programme\MIOS_base\bin/mios-gpasm modifies _output/main.asm, result in _output/main__mios-gpasm-tmp.asm
gplink -s C:\Programme\MIOS_base/etc/lkr/p18f452.lkr -m -o project.hex  C:\Programme\MIOS_base/lib/libsdcc.lib C:\Programme\MIOS_base/lib/pic18f452.lib _output/mios_wrapper.o _output/app_lcd.o _output/main.o
error: missing definition for symbol "_parse_sysex", required by "_output/main.o"
make: *** [project.hex] Error 1
<<< Process finished.
================ READY ================

/edit: removed remaining code, as error had nothing to do with it

i would be glad if you could help me out!

Thnx & Cheers :)

Alex

test.rar

test.rar

Link to comment
Share on other sites

ok, got it :)

when reading through the post once more, i realised, sdcc didn't even try to compile a midi_process.o, so added this to the makefile and everythings fine now.

i thought, i had read somewhere, that the latest release looked after this automatically. but suppose i got something wrong there.

Cheers,

Alex

Link to comment
Share on other sites

horray!!!

*dancing the it's-working-dance* :D

yesterday i finished everything, i really need. my core now translates the odd velocity response of my stage-piano to sensible values and catches most buttons from its control-surface. those are used for preset-changes, midi-channel switching and effects on/off.

most buttons on the stage-piano send a really ugly mixture of BS+PC, CC and sysex-messages. unfortunately, i cant ignore those, as other buttons send the exactly same sysex-msgs only. the code is quite a patchwork :P

10 of those buttons are then used to send the BS+PC msgs, my expander wants to see. pressing multiple times allows access to higher presets. another 2 buttons allow to change the midi-channel (resp. patch on the expander), notes and damper-CC are sent on. when a note-on is received, the box remembers the channel for each key. note-offs are then sent on the same channel. same for damper. that way i can play e.g. a chord, hold it (or use damper) and change the channel. while playing the new patch, the chord will sustain until i release keys (or damper). the 2 remaining buttons are used for all-sounds-off and toggling an effect on the expander (sysex-msg). quite trivial, but gives me a whole bunch of new options :)

ultimately, i came to the conclusion, that already now, i won't need the floorboard anymore 8)

next thing will be a propper housing. then, im thinking about using ordinary buttons and a DIN instead of the ugly button-processing. and somehow a lcd feels like a must, although i dont really need it  :)

so all together, nothing special in here. most of it is not even reusable, but it's already doing a great job for me!

cu, Alex

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...