BBC BASIC
Development >> Raspberry Pi >> I must be missing something simple ..........
http://bbcbasic.conforums.com/index.cgi?board=raspberry&action=display&num=1502151432

I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 12:17am

.......
If I don't use line numbers the commands immediately run,
but if I use a line number I get "syntax error" huhhuh
Re: I must be missing something simple ..........
Post by michael on Aug 8th, 2017, 02:02am

I find if I save my files in the directory @usr$ there are no issues.

Also, I used Renumber under Utilities and the program was numbered in increments of 10 and I had no issues.

Perhaps look carefully at your program and see where the error is. Check the cursor location.. It usually shows the general location of the error.

I tried this on the Raspberry PI3 .. If all else fails, copy and paste your program here.
Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 03:21am

Code:
BBC BASIC for Linux version 0.18a
(C) Copyright R. T. Russell. 2017
> 
>PRINT 555
            555
>10 PRINT 555

Syntax error
>_
 

Re: I must be missing something simple ..........
Post by michael on Aug 8th, 2017, 04:17am

Looks like your in immediate mode.

Restart BBC Basic and paste just the program in the editor. Then when executing the program select RUN and then the drop down menu will display Run at the top of the list.

Or press the play icon beside the gear icon.

The copyright information is a bit misleading as I don't see it in the immediate mode in BBC4W but the results are the same in that mode for the code you shown.

Perhaps look at the tutorial for beginners under HELP drop down menu on right side of editor. That is where I learned the quickest when I started.

Also make sure that the > at the start of each line is not included in your pasted code as its not part of the code.
Good Luck


Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 04:40am

The IDE on the RPi has no menus etc.
Only what I posted..............
Re: I must be missing something simple ..........
Post by michael on Aug 8th, 2017, 04:43am

Looks like you have the wrong BBC Basic downloaded.

Here is the link to the list:

http://bbcbasic.conforums.com/index.cgi?board=announcements&action=display&num=1501579415
Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 05:52am

That's the one I downloaded.
Are you on a RPi ?
Re: I must be missing something simple ..........
Post by Richard Russell on Aug 8th, 2017, 08:24am

on Aug 8th, 2017, 12:17am, hitsware wrote:
If I don't use line numbers the commands immediately run, but if I use a line number I get "syntax error"

That's perfectly normal. BBC BASIC for Windows has never had the interactive ('shell') mode of operation that older versions had - it's why commands like LIST, LOAD, NEW and SAVE don't exist! That capability is superfluous when you have an IDE.

Richard.

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 8th, 2017, 08:37am

on Aug 8th, 2017, 04:40am, hitsware wrote:
The IDE on the RPi has no menus etc.

The IDE on the RPi is identical in appearance to that on the other BBCSDL editions (except Android of course). See the screenshot below, taken from my Raspberry Pi 3. What you showed was immediate mode.

Richard.

User Image
Re: I must be missing something simple ..........
Post by michael on Aug 8th, 2017, 11:25am

The steps I take to run BBCSDL on my Raspberry PI3 are as follows:

* after booting the PI I left click on the file manager folder

* then I double left click "Downloads" folder

----My copy is unzipped in the downloads folder

* You should see a file called "bbcsdl" and it has an icon of a paper airplane

* Double Left click with your mouse

--- a window will pop up and ask "This file bbcsdl is executable. Do you want to execute it? "

* Left click on "Execute" with your mouse

You then are prompted to choose IDE

* I selected "Richard Russell's SDLIDE"

And the screen Richard shows on previous post is active.

When I save my files I make sure the files are in a folder called @usr$

And its easy from that point.


( aside from the assumption that the installation was done according to instructions.)

Here is a sample program to help you get started:

Code:
      PROCgraphics(1000,500)
      REPEAT
        resp$=FNbuttonz(100,100,"clearitall")
        resp$=FNbuttonz(100,100,"Show me a circle ")
        WAIT 1
        REPEAT
          k% = INKEY(4)
          resp%=FNmoucheck
        UNTIL k%<>-1 OR resp% >0
      UNTIL resp$="Show me a circle "
      PROCcolor("f","yellow")
      CIRCLE FILL 500,500,150
      END
      DEF FNmoucheck
      PRIVATE mx%,my%,mb%,x%,y%,b%
      MOUSE x%,y%,b%
      IF mx%=0 AND my%=0 AND mb%=0 THEN mx%=x%:my%=y%:mb%=b%: =-1
      IF mx%=x% AND my%=y% AND mb%=b% THEN =-1 ELSE  mx%=x%:my%=y%:mb%=b%:=1
      DEF PROCgraphics(x,y)
      VDU 23,22,x;y;8,15,16,1
      OFF
      VDU 5
      ENDPROC
      DEFFNbuttonz(X,Y,msg$)
      LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
      PRIVATE st$
      IF msg$<> "clearitall" THEN
        initialx%=LEN(msg$)
        LET tx= X+initialx%+25
        LET ty= Y:reduction%=0
        reduction%=initialx%/2
        reduction%=reduction%*6
        IF initialx%<20 THEN reduction%=reduction%/2
        initialx%=initialx%*22-reduction%
        MOUSE mx%,my%,mb%
        ad%=initialx%+8:ad%+=X:ady%=Y-28
        IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
          c$="255,255,255"
          IF mb%=4 THEN st$=msg$
        ELSE c$="200,200,200"
        ENDIF
        IF FNrgb(X,Y)="000,000,000" THEN c$="200,200,200"
        PROCcolor("f",c$)
        IF FNrgb(X,Y)<>c$ THEN
          FOR fi%=12 TO 48
            LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
          NEXT
          PROCcolor("f","000,000,000")
          MOVE tx,ty
          PRINT msg$
        ENDIF
      ENDIF
      IF msg$="clearitall" THEN st$=""
      MOVE 0,0 REM hide that thing
      =st$
      DEF PROCcolor(fb$,rgb$)
      PRIVATE assemble$,br%,bg%,bb%
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magenta" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magenta" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
      DEFFNrgb(x%,y%)
      LOCAL rgb%, r&, g&, b&
      rgb%=TINT(x%,y%)
      r&=rgb%    :REM Use byte variable as mask.
      g&=rgb% >>8
      b&=rgb% >>16
      =FNnumstr(r&)+","+FNnumstr(g&)+","+FNnumstr(b&)
      DEFFNnumstr(num)
      LOCAL cov$,l%
      cov$=STR$(num)
      l%=LEN(cov$)
      IF l%=1 THEN ret$="00"+cov$
      IF l%=2 THEN ret$="0"+cov$
      IF l%=3 THEN ret$=cov$
      =ret$
 

Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 1:14pm

OK .....Got it..........I was using " ./bbcsdl " from the terminal ( or >run )
to open. ( which is what the instructions say ) ?
Thank You smiley
Re: I must be missing something simple ..........
Post by Richard Russell on Aug 8th, 2017, 2:42pm

on Aug 8th, 2017, 1:14pm, hitsware wrote:
I was using " ./bbcsdl " from the terminal

That's fine, it's the way I always start it myself. For it to start up in immediate mode you must be typing something (anything) after the ./bbcsdl (it's expecting a filename there and if the file doesn't exist that's the effect).

Richard.
Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 3:00pm

on Aug 8th, 2017, 2:42pm, Richard Russell wrote:
For it to start up in immediate mode you must be typing something (anything) after the ./bbcsdl (it's expecting a filename there and if the file doesn't exist that's the effect).

Richard.

I'm not ....Where do you keep the executable ?
It probably has something to do with that.
I can't get SYS to work ?
Should be like terminal inputs ....
Re: I must be missing something simple ..........
Post by Richard Russell on Aug 8th, 2017, 10:15pm

on Aug 8th, 2017, 3:00pm, hitsware wrote:
Where do you keep the executable ?

Wherever you extracted the Zip! It's entirely your choice.

Quote:
I can't get SYS to work ?

Many of the supplied example programs rely on SYS, so if they are running then obviously SYS is working correctly. For example you can try any of the 3D programs (e.g. 'teapot.bbc') which depend heavily on SYS.

If you need to check the syntax and parameters etc. of SYS in BBCSDL, there is an API reference here (the closest you'll get to an MSDN equivalent, but obviously the SDL API is very much simpler than the Win32 API).

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 8th, 2017, 11:24pm

Hmmm ..... Does "SYS" in SDL act as if writing in the terminal ?
I.E. The below code in BASIC-256 or RUBY will play Midi notes
as if using Alsa commands in the terminal (amidi, aconnect, etc.)

Code:
system "sudo modprobe snd-virmidi snd_index=0"
system "aconnect 20:0 128:0"
do
system "amidi -p hw:1,0 -S'90 3C 7F' "
system "amidi -p hw:1,0 -S'90 3C 0' "
pause 1
until false
end
 

Using the below: (inBBC) I get "no such System call"
Actually some kind of Midi Command without the SYS(tem?)
would be slicker ......
Code:
      SYS "sudo modprobe snd-virmidi snd_index=0 "
      SYS "aconnect 20:0 128:0"
      REPEAT
        SYS "amidi -p hw:1,0 -S'90 3c 7f'"
        SYS "amidi -p hw:1,0 -S'90 3c 0' "
        WAIT 22
      UNTIL FALSE
 

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 9th, 2017, 03:29am

on Aug 8th, 2017, 11:24pm, hitsware wrote:
Using the below (in BBC) I get "no such System call"

You've omitted the "system" command verb that the original code had, which isn't right. In BBC BASIC you should be using something more like this (untried):

Code:
      SYS "system", "sudo modprobe snd-virmidi snd_index=0"
      SYS "system", "aconnect 20:0 128:0"
      REPEAT
        SYS "system", "amidi -p hw:1,0 -S'90 3C 7F' "
        SYS "system", "amidi -p hw:1,0 -S'90 3C 0' "
        WAIT 22
      UNTIL FALSE
      END 

Of course even if this code works on the Raspberry Pi it isn't 'cross-platform' so runs somewhat contrary to the spirit of BBCSDL.

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 9th, 2017, 05:54am

Code:
SYS "system", "amidi -p hw:1,0 -S'90 3C 7F' "
SYS "system", "amidi -p hw:1,0 -S'90 3C 0' "
 

It works !!!!!!!!!!!!
How can I put decimal variables into the hex numbers
at the end of the amidi statements ?
FWIW Here's the Ruby way ::::::::::;
Code:
### MIDIPI #######################

# Assumes Timidity installed
# Works on RPi .... Maybe other LinuxMachines ?
# In terminal type 'timidity -iA'
# Leave terminal open

system"sudo modprobe snd-virmidi snd_index=0"#Alsa
system"aconnect 20:0 128:0"                  #Connect

scale=[48,50,52,53,55,57,59,60]              #MidiScale

a=144.to_s(16)                               #Convert
c=127.to_s(16)                               #MidiData
d=0.to_s(16)                                 #to hex

for i in 0..7                                #PlayScale
  b=scale[i].to_s(16)
  system"amidi -p hw:1,0 -S'#{a}#{b}#{c}'"
  system"amidi -p hw:1,0 -S'#{a}#{b}#{d}'"
  sleep 1
end
 

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 9th, 2017, 08:48am

on Aug 9th, 2017, 05:54am, hitsware wrote:
How can I put decimal variables into the hex numbers

In BBC BASIC the function for converting to a hexadecimal string is STR$~(), note the tilde after the STR$.

Incidentally I didn't address your previous question:

Quote:
Does "SYS" in SDL act as if writing in the terminal?

SYS calls an API function. In BBC BASIC the way to run a 'shell' command is *RUN (conventionally pronounced 'star run') or in most cases just precede the command with an asterisk. So it may well be that this would have worked as well:

Code:
      *amidi -p hw:1,0 -S'90 3C 7F'
      *amidi -p hw:1,0 -S'90 3C 0' 

However you cannot directly incorporate variables in 'star' commands and must use the OSCLI statement in that case. This is all documented in the help file.

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 10th, 2017, 3:53pm

Even though the 2 PRINT's read the same,
only the one without the STR's works in the SYS commands...
I can't figure out how to use the OSCLI ???
Code:
  b0=144: b1=60: b2=127

  SYS "system", " sudo modprobe snd-virmidi snd_index=0 "
  SYS "system", " aconnect 20:0 128:0 "
  PRINT" amidi -p hw:1,0 -S'90 3C 7F'"
  PRINT" amidi -p hw:1,0 -S'"STR$~(b0)" "STR$~(b1)" "STR$~(b2)"'"

  REPEAT
  REM: SYS "system", " amidi -p hw:1,0 -S'90 3C 7F'"
  SYS "system", " amidi -p hw:1,0 -S'"STR$~(b0)" "STR$~(b1)" "STR$~(b2)"'"
  SYS "system", " amidi -p hw:1,0 -S'90 3C 0' "
  WAIT 22
  UNTIL FALSE
  END
 

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 10th, 2017, 8:17pm

on Aug 10th, 2017, 3:53pm, hitsware wrote:
Even though the 2 PRINT's read the same, only the one without the STR's works in the SYS commands...

PRINT is an unusual statement, for example it can take a list of arguments that are printed one after the other. No other statement in BASIC works like that. Compare these two examples:

Code:
      PRINT "The " "quick " "brown " "fox"
      PRINT "The "+"quick "+"brown "+"fox" 

They appear to do exactly the same thing, but they work completely differently under the hood. Again, compare these two:

Code:
      SYS "system", " amidi -p hw:1,0 -S'" STR$~(b0) " " STR$~(b1) " " STR$~(b2) "'"
      SYS "system", " amidi -p hw:1,0 -S'"+STR$~(b0)+" "+STR$~(b1)+" "+STR$~(b2)+"'" 

The first is your code, but it can't work because SYS isn't like PRINT. The second correctly concatenates the strings using the + operator.

This is very 'basic' stuff!

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 11th, 2017, 12:02am

The ide is sure clunky, but it works ;D ..... Thank You once again !!!!
Code:
 REM: ######## RPi Midi Explorer ################

 REM: Assumes Timidity installed
 REM: In terminal enter ' timidity -iA ' ( leave terminal open )

 REM: midi setup
 SYS "system", " sudo modprobe snd-virmidi snd_index=0 "
 SYS "system", " aconnect 20:0 128:0 "

 REM: firstnote
 midipatch = 0: midinote = 55

 REM: start
 PROC_playnote(midipatch, midinote)

 REM: set patches and notes
 REPEAT: REPEAT: x=INKEY(2): UNTIL x <> -1
 IF x = 139 THEN midipatch = midipatch + 1
 IF x = 138 THEN midipatch = midipatch - 1
 IF x = 137 THEN midinote = midinote + 1
 IF x = 136 THEN midinote = midinote - 1
 IF midipatch < 0 THEN midipatch = 0
 IF midipatch >127 THEN midipatch = 127
 IF midinote < 0 THEN midinote = 0
 IF midinote > 127 THEN midinote = 127
 PROC_playnote(midipatch, midinote)
 UNTIL FALSE: END

 REM: play and display
 DEF PROC_playnote(midipatch,midinote)
 SYS "system", " amidi -p hw:1,0 -S'C0 "+STR$~(midipatch)+"'"
 SYS "system", " amidi -p hw:1,0 -S'90 "+STR$~(midinote)+" 7F'"
 WAIT 5   REM: adjust waitime for sustain     
 SYS "system", " amidi -p hw:1,0 -S'B0 7B 0'"
 CLS
 PRINT "midipatch = "; midipatch ;"        midinote = "; midinote
 PRINT " up / down arrows for patch change"
 PRINT "left / right arrows for note change"
 ENDPROC
 






Re: I must be missing something simple ..........
Post by Richard Russell on Aug 11th, 2017, 06:47am

on Aug 11th, 2017, 12:02am, hitsware wrote:
The ide is sure clunky

If by "clunky" you mean slow, the reason is almost certainly that you haven't enabled the GL Driver. As it explains in the installation instructions, BBC BASIC will run very slowly without that driver (and use excessive amounts of CPU time), because the graphics aren't accelerated. You will also find that none of the 3D programs run*.

On the other hand if by "clunky" you mean something else, please give details. The IDE works beautifully on the Raspberry Pi here, almost as well as it works on Linux (86) or Mac OS, which is remarkable given the relatively slow ARM CPU in the RPi.

Richard.

* Actually they do run, but slowly, because SDL falls back to a software driver.

Re: I must be missing something simple ..........
Post by hitsware on Aug 11th, 2017, 2:59pm

> If by "clunky" you mean slow,
> the reason is almost certainly that
> you haven't enabled the GL Driver.

Slow is an understatement.
Which model RPi do you have ?
I tried the GL Driver.
It definitely speeds up your visual examples.
Also somewhat speeds up the IDE but not enough.
For some reason it makes my midi not connect.
(maybe needs some pauses to allow execution)
Also seems to cause some irregular blips in the display ?
Anyways ...... SLOW and UNRESPONSIVE undecided
( Compare it to ( say ) LeafPad )
It acts like (perhaps) it is last in the priority list.
I think this is adjustable, but beyond my paygrade grin
I may have messed up the installation ?
First time I installed beyond ' apt-get '
Also I'm an obsessive tinkerer, and may have huh??
The proof in the pudding will be when I do a ditty
and see if it keeps a beat. I can always edit in LeafPad
then copy/paste, but shouldn't have to.
HyperRegards .......... Mike Miller
Re: I must be missing something simple ..........
Post by Richard Russell on Aug 11th, 2017, 4:00pm

on Aug 11th, 2017, 2:59pm, hitsware wrote:
Slow is an understatement. Which model RPi do you have ?

It's an RPi 3 (the current model). Anything earlier would of course be slow, but then I don't claim BBC BASIC will work on earlier models anyway. wink

Quote:
I tried the GL Driver. It definitely speeds up your visual examples. Also somewhat speeds up the IDE but not enough.

It speeds up all aspects of screen output (graphics and text) and the IDE particularly benefits. On the RPi 3 with GL Driver enabled the IDE is plenty fast enough.

Quote:
For some reason it makes my midi not connect.

As you know, the GL Driver is described as 'experimental' and with good reason. Interference with HDMI sound output is a known bug (it used to be OK, but they seem to have introduced the problem in a recent update). I queried this at the Raspberry Pi forum and apparently there are no plans to fix it in Raspbian Jessie, we will have to wait for Raspbian Stretch for a 'stable' GL Driver.

If the sound problems force you to leave the GL Driver disabled, BBC BASIC will unavoidably be very slow, sorry.

I am absolutely delighted with the Raspberry Pi edition of BBC BASIC: it exceeds my expectations by a large margin (remember, the RPi costs only about 30 so you shouldn't make comparisons with a desktop PC or Android device costing hundreds of pounds). grin

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 11th, 2017, 4:44pm

Quote:
I am absolutely delighted with the Raspberry Pi edition of BBC BASIC:

Me too overall.
I'm delighted by the whole RPi scene.
Jolly Old England has done the world proud !
Re: I must be missing something simple ..........
Post by hitsware on Aug 12th, 2017, 1:55pm

Richard, (or anyone interested)
Would you please try this:
Run the below (slightly modified) routine
Hold down the right arrow key a short time
How fast do the notes change ?

Code:
      REM:#### RPi Midi Explorer #################

      REM: Assumes Timidity installed
      REM: In terminal enter ' timidity -iA ' ( leave terminal open )

      REM: midi setup
      SYS "system", " sudo modprobe snd-virmidi snd_index=0 "
      SYS "system", " aconnect 20:0 128:0 "

      REM: firstnote
      midipatch = 0: midinote = 55

      REM: start
      PROC_playnote(midipatch, midinote)

      REM: set patches and notes
      REPEAT: REPEAT: x=INKEY(0): UNTIL x <> -1
        IF x = 139 THEN midipatch = midipatch + 1
        IF x = 138 THEN midipatch = midipatch - 1
        IF x = 137 THEN midinote = midinote + 1
        IF x = 136 THEN midinote = midinote - 1
        IF midipatch < 0 THEN midipatch = 0
        IF midipatch >127 THEN midipatch = 127
        IF midinote < 0 THEN midinote = 0
        IF midinote > 127 THEN midinote = 127
        PROC_playnote(midipatch, midinote)
      UNTIL FALSE: END

      REM: play and display
      DEF PROC_playnote(midipatch,midinote)
      SYS "system", " amidi -p hw:1,0 -S'C0 "+STR$~(midipatch)+"'"
      SYS "system", " amidi -p hw:1,0 -S'90 "+STR$~(midinote)+" 7F'"
      SYS "system", " amidi -p hw:1,0 -S'B0 7B 0'"
      CLS
      PRINT "midipatch = "; midipatch ;"        midinote = "; midinote
      PRINT " up / down arrows for patch change"
      PRINT "left / right arrows for note change"
      ENDPROC
 




Re: I must be missing something simple ..........
Post by Richard Russell on Aug 12th, 2017, 5:54pm

on Aug 12th, 2017, 1:55pm, hitsware wrote:
How fast do the notes change ?

I don't get any sound from your program on my RPi 3. sad

The rate at which the notes are produced will in any case depend on the keyboard repeat speed, and since that won't necessarily be consistent between systems I'm not sure what your test is trying to determine.

Also, there's a CLS in your playnote routine and that will slow things down quite a bit.

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 12th, 2017, 6:21pm

If you've done the below then it may be the GL driver.........
Anyways it should (has on any other platform) sweep like
running your hand accross a (piano)keyboard .....
~ 20 notes/sec.
This runs more like at least 1/2 second for each note

REM: Assumes Timidity installed
REM: In terminal enter ' timidity -iA ' ( leave terminal open )
Re: I must be missing something simple ..........
Post by Richard Russell on Aug 12th, 2017, 7:03pm

on Aug 12th, 2017, 6:21pm, hitsware wrote:
This runs more like at least 1/2 second for each note

Well, the slowness has nothing to do with BBC BASIC, it's just how long those SYS statements happen to take (delete the CLS and PRINT to make sure they are not contributing). I'm sure you didn't seriously think that BBC BASIC would take 0.5 seconds to execute half a dozen statements! A few microseconds more like. smiley

Perhaps you should be running the commands in the background, rather than waiting for them to complete?

Edit: Why are you splitting the MIDI commands into three 'amidi' statements rather than using just one? Surely that just adds unnecessary overhead?

Richard.

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 12th, 2017, 8:29pm

on Aug 12th, 2017, 7:03pm, Richard Russell wrote:
Perhaps you should be running the commands in the background, rather than waiting for them to complete?

That makes a big difference (try the code below).

Richard.

Code:
      SYS "system", "sudo modprobe snd-virmidi snd_index=0"
      SYS "system", "aconnect 20:0 128:0"

      midipatch=0
      midinote=55
      PROCplaynote(midipatch, midinote)
      REPEAT
        CASE GET OF
          WHEN 139: IF midipatch < 127 midipatch += 1
          WHEN 138: IF midipatch > 1   midipatch -= 1
          WHEN 137: IF midinote < 127 midinote += 1
          WHEN 136: IF midinote > 1   midinote -= 1
        ENDCASE
        PROCplaynote(midipatch, midinote)
      UNTIL FALSE
      END

      DEF PROCplaynote(midipatch,midinote)
      OSCLI "amidi -p hw:1,0 -S'C0 "+STR$~(midipatch)+" 90 "+STR$~(midinote)+" 7F' ;"
      OSCLI "amidi -p hw:1,0 -S'B0 7B 0' ;"
      PRINT midipatch, midinote
      ENDPROC 


Re: I must be missing something simple ..........
Post by hitsware on Aug 12th, 2017, 8:45pm

Yep !
I just tried the same routine in Ruby as well as Sonic-Pi
the ' system ' commands themselves (away from BBCB)
take mucho tiempo. ( ~ 1/4 sec. )
I'll have to find another way to write to Timidity ......

edit: My guess was pretty good ...... 0.33 sec.
Code:
      TIME=0
      SYS "system","amidi -p hw:1,0 -S'90 #{hmn} 7F'"
      SYS "system","amidi -p hw:1,0 -S'B0 7B 0'"
      x=TIME
      PRINT x
 

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 12th, 2017, 9:09pm

on Aug 12th, 2017, 8:45pm, hitsware wrote:
I'll have to find another way to write to Timidity ......

Did you not read my latest message (posted 15 minutes before yours)? Running the amidi commands in the background speeds them up hugely here (although obviously there's a danger of them 'overlapping', depending on how reliably timidity manages to serialise them).

But since the GL Driver appears to be incompatible with MIDI sound, and without it BBC BASIC is unusably slow (I tried, but it's impossible), you will have no choice but to find an alternative approach.

Perhaps you might consider returning to BBC BASIC when Raspbian Stretch is released and (hopefully) the GL Driver is stable and doesn't break other things.

Richard.
Re: I must be missing something simple ..........
Post by hitsware on Aug 12th, 2017, 9:51pm

on Aug 12th, 2017, 9:09pm, Richard Russell wrote:
Did you not read my latest message (posted 15 minutes before yours)? Running the amidi commands in the background speeds them up hugely here (although obviously there's a danger of them 'overlapping', depending on how reliably timidity manages to serialise them).

But since the GL Driver appears to be incompatible with MIDI sound, and without it BBC BASIC is unusably slow (I tried, but it's impossible), you will have no choice but to find an alternative approach.

Perhaps you might consider returning to BBC BASIC when Raspbian Stretch is released and (hopefully) the GL Driver is stable and doesn't break other things.

Richard.

How does one "run commands in the backround" ?
It's not the BBC BASIC as much as the 'system' commands
They bog down even Sonic-Pi which is quite good time-wise
By another approach, I mean an address (file) to write to rather
than making the 'system' commands.
probably something like " /dev/snd/midiC1D0 "
see: https://wiki.archlinux.org/index.php/Timidity

Re: I must be missing something simple ..........
Post by Richard Russell on Aug 12th, 2017, 10:25pm

on Aug 12th, 2017, 9:51pm, hitsware wrote:
How does one "run commands in the backround" ?

It's documented in the BB4W manual under *RUN. Apparently you can't see, or haven't bothered to read, my post (it's reply #29 in the thread) which contains a complete program demonstrating it. It plays the notes very quickly.

Quote:
It's not the BBC BASIC as much as the 'system' commands

'system' commands aren't slow, certainly not in the sort of timescale relevant to music. The issue appears to be that the amidi command takes quite a time before it returns. Running it in the background means that you don't need to wait until it returns, but with the risks outlined in my previous post.

I'm locking this thread now before it drives me completely mad. angry

Richard.

Re: I must be missing something simple ..........
Post by hitsware on Aug 12th, 2017, 10:45pm

Sorry ....... My seeing eye reading dog must have been distracted rolleyes