![]() |
Forum Index : Microcontroller and PC projects : Introducing the Pi-cromite: first steps
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
I have not found a version (and I have searched) of Basic for the RPi that will write midi messages to the gpio's. BEST ! Would be able to write to a USB serial port. (directly from the RPi to the midi synth rather than through a MicroMite with a terminal program. |
||||
PicFan Senior Member ![]() Joined: 18/03/2014 Location: AustriaPosts: 133 |
Works perfect, thank you ! I have run a test with 4 Setticks - no problem ! |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Just so you know, some of us are aware that you are simply asking if it is possible to generate a MIDI compatible baud within MMBasic on the Pi ;) |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
Ya Mon ![]() |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4033 |
Once you have suitable hardware the answer is inevitably yes. John |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
I have "suitable hardware" to program midi music with a PC. With BBCBasic I open a usb serial 'com' link to a midi-synth with usb adaptor. (set baud to 31250) I would like to do the same with simply the RPi and MMBasic. |
||||
panky![]() Guru ![]() Joined: 02/10/2012 Location: AustraliaPosts: 1114 |
@hitsaware My understanding of your requirements are:- 1. Using a Micromite and/or a Pi, initialise a serial output to 31250baud and send a midi file, byte by byte, to a Midi synthesiser which would convert the midi control codes to audio sound? If this is correct, a micromite plus using COM1 would be able to satisfy your requirements. You could also use a Pi running matherp's implimentation of MMBasic for the Pi psuedo code - not proper MMBasic but just read the manual open COM1 as output #1 open midifile for input as #2 while not end of input file get byte from midifile send byte out COM1 loop ..... or 2. Alternatively, if you want a Micromite (or a Pi) to receive midi data and control bytes and convert them to audio sound, doing so would be somewhat more complex. In fact, anything other than monotonic sounds (ie. single notes) would be quite complex to program. For single notes, perhaps a note table that has PWM frequencies in it and a send_note subroutine that acepts a note number aa input and sets the PWM to the frequency relating to the note. You would need to parse the incoming midi data stream, decoding the note on, note off, velocity etc. codes to turn the PWM on and off accordingly. At the midi serial interface baud rate of 31,250 baud, a midi byte arrives about every 320 uSecs, so you don't have very much time to use for processing the input stream. The Micromite Plus at 120MHz processes a MMBasic instruction around every 20uSec thus you really only have about 15 MMBasic lines of code to work with - just not enough do do anything usefull with therefore, either a Micromite Extreme at 252MHz or a Pi running MMBasic are your only real options for this task. Hope this has been helpfull, Cheers, Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
New minor update 5.3a4. This has the floating point formatting re-written and will now output as many significant digits as required. ![]() 2017-04-17_142750_mmbasic.zip |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
@ Doug Thank You and yes. I have done it with both a DuinoMite and a MicroMite. I'm trying to get away from anything more than the synth (besides the PC(RPi)) |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
5.3a4 had a couple of bugs - new copy attached 2017-04-17_185159_mmbasic.zip |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
5.3a5 attached up-to-date with all the floating point formatting changes from the MMX 2017-04-19_083119_mmbasic.zip |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6266 |
There appears to be a problem when the argument for a function is another function f$=" test "+chr$(9)+" " print "*";f$;"*" print "*";rtrim$(f$);"*" print "*";ltrim$(f$);"*" 'F$=ltrim$(f$) print "*";rtrim$(ltrim$(f$));"*" FUNCTION LTrim$(a$) LOCAL n if len(a$)=0 then LTrim$ = "" else FOR n= 1 TO LEN(a$) IF MID$(a$,n,1)<>" " and MID$(a$,n,1)<>CHR$(9) THEN exit for NEXT n LTrim$=mid$(a$,n) endif END FUNCTION FUNCTION RTrim$(a$) LOCAL n if len(a$)=0 then RTrim$ = "" else FOR n= LEN(a$) TO 1 step -1 IF MID$(a$,n,1)<>" " and MID$(a$,n,1)<>CHR$(9) THEN exit for NEXT n RTrim$=left$(a$,n) endif END FUNCTION It works correctly on the MMX with latest firmware doing F$=ltrim$(f$) print "*";rtrim$(F$);"*" gets around the issue. I think I saw something similar a few days ago but I forget which device it was on. Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
Jim Thanks for the report but I'm struggling with this one. As far as I can see it works if either function is built in and it works if the user functions are float or integer. You have found the one case where it doesn't - where both functions are string and both are user defined. I'll continue looking but the code is exactly the same as the MMX so it may be some subtle compiler difference. |
||||
PicFan Senior Member ![]() Joined: 18/03/2014 Location: AustriaPosts: 133 |
Hello matterp ! Please try this. print 99999 + 0.1 print 100000 + 0.1 print 100001 - 0.1 print 99999 - 0.1 OUTPUT: 99999.1 100000 100001 99998.9 Thank you ! Wolfgang |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
Try it on an ordinary Micromite and you will find the same. This is just the way that the Micromite code defaults output of floats. Use str$ to get more reolution |
||||
PicFan Senior Member ![]() Joined: 18/03/2014 Location: AustriaPosts: 133 |
All right, thank you ! Wolfgang |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
Minor update to improve use of ILI9481 display - see the thread on pi-zero 2017-04-22_152528_mmbasic.zip |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 724 |
Hi, fantastic project. Thank you Peter/Geoff!!!! ![]() ![]() ![]() ![]() ![]() ![]() Just started to play with my zero W and PICROMITE ;-).. Will there be some kind of documentation for the Picromite, explaining the Linux environmemt and some special things to concider beside the standard documentation? THX |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10195 |
Left some diagnostics in - now removed (I hope) Documentation if/when I get more working ![]() Fixed bugs in GUI commands Fixed incorrect error in KILL command Printing 0.0 in exponential format now works properly e.g. str$(0.0,1,-15) 2017-04-22_174638_mmbasic.zip |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6266 |
A strange 'feature' entering programs with AUTO AUTO paste the program .... endif END FUNCTION ^C run > Error: Failed to open file > The second attempt at RUN is OK When you exit the AUTO mode with ^C the '>' prompt does not appear. Pressing ENTER will give the prompt and RUN is successful. It only fails if you try without the prompt showing. LIST also fails with Error: Failed to open file if you don't press ENTER first (after using AUTO). VK7JH MMedit |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |