Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:48 04 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Introducing the Pi-cromite: first steps

     Page 5 of 16    
Author Message
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 06:24am 15 Apr 2017
Copy link to clipboard 
Print this post

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: Austria
Posts: 133
Posted: 07:08am 15 Apr 2017
Copy link to clipboard 
Print this post

  matherp said   Wolfgang

Sounds like you are running a different version of pigpio

Try following instructions here to install the same version as me

Did you get pigpio using apt-get? if so it looks like the version there is out-of-date



Works perfect, thank you ! I have run a test with 4 Setticks - no problem !

 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:50am 15 Apr 2017
Copy link to clipboard 
Print this post

  hitsware said   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.


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 States
Posts: 535
Posted: 08:45am 15 Apr 2017
Copy link to clipboard 
Print this post

Ya Mon
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4033
Posted: 03:42am 16 Apr 2017
Copy link to clipboard 
Print this post

Once you have suitable hardware the answer is inevitably yes.

John
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 07:35am 16 Apr 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 1114
Posted: 05:55pm 16 Apr 2017
Copy link to clipboard 
Print this post

@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 Kingdom
Posts: 10195
Posted: 04:28am 17 Apr 2017
Copy link to clipboard 
Print this post

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 States
Posts: 535
Posted: 05:27am 17 Apr 2017
Copy link to clipboard 
Print this post

@ 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 Kingdom
Posts: 10195
Posted: 08:52am 17 Apr 2017
Copy link to clipboard 
Print this post

5.3a4 had a couple of bugs - new copy attached

2017-04-17_185159_mmbasic.zip
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 10:31pm 18 Apr 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 6266
Posted: 06:37pm 19 Apr 2017
Copy link to clipboard 
Print this post

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


  Quote  [6] Print "*";rtrim$(ltrim$(f$));"*"
Error: Expected a number


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 Kingdom
Posts: 10195
Posted: 11:24pm 20 Apr 2017
Copy link to clipboard 
Print this post

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: Austria
Posts: 133
Posted: 01:00am 22 Apr 2017
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10195
Posted: 01:17am 22 Apr 2017
Copy link to clipboard 
Print this post

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 reolutionEdited by matherp 2017-04-23
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 01:37am 22 Apr 2017
Copy link to clipboard 
Print this post

  matherp said   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



All right, thank you !

Wolfgang
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 04:40am 22 Apr 2017
Copy link to clipboard 
Print this post

Minor update to improve use of ILI9481 display - see the thread on pi-zero

2017-04-22_152528_mmbasic.zip Edited by matherp 2017-04-23
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 05:44am 22 Apr 2017
Copy link to clipboard 
Print this post

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
Edited by atmega8 2017-04-23
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10195
Posted: 06:31am 22 Apr 2017
Copy link to clipboard 
Print this post

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 Edited by matherp 2017-04-23
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 02:43pm 22 Apr 2017
Copy link to clipboard 
Print this post

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
 
     Page 5 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025