Hi,
How to create the PB-code which does the same as this alsa-command amidi -p hw:1,0,0 -r /dev/null -t 1
I need to send it to initialize my interface, the command does it's work from the terminal.
But I would like to send it with PB code. I have anything else ready in PB code, to select the port hw:1,0,0.
This, without having the need of the terminal.
Thanks.
How to implement this (terminal) command ?
How to implement this (terminal) command ?
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Re: How to implement this (terminal) command ?
You have to look in the source code of amidi.
I don't know what amidi does internally.
https://github.com/bear24rw/alsa-utils/ ... di/amidi.c
Now you have to look for snd_rawmidi_open
It's located in rawmidi.c
https://github.com/michaelwu/alsa-lib/b ... /rawmidi.c
But I think in the end something in /dev/snd/ ... is opened in nonblocking mode.
The default midi device can be /dev/midi, which should be a symbloic link to the device itself.
https://ccrma.stanford.edu/~craig/articles/linuxmidi/
I don't know what amidi does internally.
https://github.com/bear24rw/alsa-utils/ ... di/amidi.c
Code: Select all
snd_rawmidi_open(inputp, outputp, port_name, SND_RAWMIDI_NONBLOCK)It's located in rawmidi.c
https://github.com/michaelwu/alsa-lib/b ... /rawmidi.c
But I think in the end something in /dev/snd/ ... is opened in nonblocking mode.
The default midi device can be /dev/midi, which should be a symbloic link to the device itself.
https://ccrma.stanford.edu/~craig/articles/linuxmidi/
Re: How to implement this (terminal) command ?
infratec, Bitblazer
I can do a snd_rawmidi_write(hnd, @buffer, len) or snd_rawmidi_read(hnd, @buffer, len) with sysex strings upto several kBytes. But that specific string is absolutely no midi data -p hw:1,0,0 -r /dev/null -t 1
Besides, this part hw:1,0,0 is formed by the specific midi port, which I also can determine and select.
But how to handle the rest, -p and -r /dev/null -t 1, how to send that complete thing via midi ?
Maybe Bitblazer's way can be of help, if I can get it figured out like should (didn't succeed with many try outs).
But as I can handle all types of midi data, I prefer doing it that way.
Usage: amidi options
-h, --help this help
-V, --version print current version
-l, --list-devices list all hardware ports
-L, --list-rawmidis list all RawMIDI definitions
-p, --port=name select port by name **************
-s, --send=file send the contents of a (.syx) file
-r, --receive=file write received data into a file **************
-S, --send-hex="..." send hexadecimal bytes
-d, --dump print received data as hexadecimal bytes
-t, --timeout=seconds exits when no data has been received
for the specified duration **************
-a, --active-sensing include active sensing bytes
-c, --clock include clock bytes
-i, --sysex-interval=mseconds delay in between each SysEx message
I can do a snd_rawmidi_write(hnd, @buffer, len) or snd_rawmidi_read(hnd, @buffer, len) with sysex strings upto several kBytes. But that specific string is absolutely no midi data -p hw:1,0,0 -r /dev/null -t 1
Besides, this part hw:1,0,0 is formed by the specific midi port, which I also can determine and select.
But how to handle the rest, -p and -r /dev/null -t 1, how to send that complete thing via midi ?
Maybe Bitblazer's way can be of help, if I can get it figured out like should (didn't succeed with many try outs).
But as I can handle all types of midi data, I prefer doing it that way.
Code: Select all
Compiler = RunProgram("/usr/bin/xterm", "", "", #PB_Program_Open | #PB_Program_Read) ; |#PB_Program_Write|#PB_Program_Connect)
Output$ = "amidi -p hw:1,0,0 -r /dev/null -t 1"
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
WriteProgramString(Compiler, Output$, #PB_UTF8)
;Output$ + ReadProgramString(Compiler) + Chr(13)
EndIf
Wend
Output$ + Chr(13) + Chr(13)
Output$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
CloseProgram(Compiler) ; Close the connection to the program
EndIf
MessageRequester("Output", Output$)
-h, --help this help
-V, --version print current version
-l, --list-devices list all hardware ports
-L, --list-rawmidis list all RawMIDI definitions
-p, --port=name select port by name **************
-s, --send=file send the contents of a (.syx) file
-r, --receive=file write received data into a file **************
-S, --send-hex="..." send hexadecimal bytes
-d, --dump print received data as hexadecimal bytes
-t, --timeout=seconds exits when no data has been received
for the specified duration **************
-a, --active-sensing include active sensing bytes
-c, --clock include clock bytes
-i, --sysex-interval=mseconds delay in between each SysEx message
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Re: How to implement this (terminal) command ?
maybe this works for you
Code: Select all
OpenConsole()
command.s = "-p hw:1,0,0 -r /dev/null -t 1"
dir.s = GetCurrentDirectory()
Compiler = RunProgram("amidi",command, dir, #PB_Program_Open | #PB_Program_Read)
Output$ = "amidi -p hw:1,0,0 -r /dev/null -t 1"
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
PrintN(ReadProgramString(Compiler))
EndIf
Wend
PrintN("Exitcode: " + Str(ProgramExitCode(Compiler)))
CloseProgram(Compiler)
EndIf
PrintN("Hit any key to exit")
Input()
CloseConsole()
Re: How to implement this (terminal) command ?
idle,
Thank you very much.
That does the job excellently.
A strange thing about that command is, that when proceeded in the termina,l it returns '12 bytes received'.
Why I don't know, but your solution is good.
Thank you very much.
That does the job excellently.
A strange thing about that command is, that when proceeded in the termina,l it returns '12 bytes received'.
Why I don't know, but your solution is good.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.


