BBC BASIC
« I must be missing something simple .......... »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 11:02pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 locked  Author  Topic: I must be missing something simple ..........  (Read 2003 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #11 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.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #12 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 ....
User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #13 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.
« Last Edit: Aug 8th, 2017, 10:21pm by Richard Russell » User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #14 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
 
« Last Edit: Aug 8th, 2017, 11:32pm by hitsware » User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #15 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.
« Last Edit: Aug 9th, 2017, 03:37am by Richard Russell » User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #16 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
 
User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #17 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.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #18 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
 
« Last Edit: Aug 10th, 2017, 3:55pm by hitsware » User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #19 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.
« Last Edit: Aug 10th, 2017, 10:02pm by Richard Russell » User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #20 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
 





« Last Edit: Aug 11th, 2017, 12:09am by hitsware » User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #21 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.
« Last Edit: Aug 11th, 2017, 5:13pm by Richard Russell » User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #22 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
User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: I must be missing something simple ..........
« Reply #23 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.
User IP Logged

hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #24 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 !
« Last Edit: Aug 11th, 2017, 4:45pm by hitsware » User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
hitsware
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 51
xx Re: I must be missing something simple ..........
« Reply #25 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
 



User IP Logged

https://www.youtube.com/watch?v=ePhUBBGyVmI
Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls