Skip to content

Commit

Permalink
Merge branch 'experimental'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Kelly committed May 18, 2019
2 parents 606c7e3 + af84b1f commit 4192cd7
Show file tree
Hide file tree
Showing 42 changed files with 2,189 additions and 650 deletions.
114 changes: 114 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,117 @@ publish-aaaa-on-ipv4=no
```
Obviously, if you want to use IPv6, both those options should be set to yes
You will need to restart Avahi for those changes to be picked up.

2. How to configure and test ALSA Support

The autotools configure script will automatically detect the presence of ALSA libraries and will build the code for support.
raveloxmidi uses the rawmidi interface so the snd-virmidi module must be loaded.

The following steps can be taken to test everything is working:

1. Ensure the snd-virmidi module is loaded.

```modprobe snd-virmidi```

2. Verify the device names

```sudo amidi -l``` will give output like
```
Dir Device Name
IO hw:0,0 ES1371
IO hw:1,0 Virtual Raw MIDI (16 subdevices)
IO hw:1,1 Virtual Raw MIDI (16 subdevices)
IO hw:1,2 Virtual Raw MIDI (16 subdevices)
IO hw:1,3 Virtual Raw MIDI (16 subdevices)
```

3. Install timidity and run it with the ALSA interface

```timidity -iA``` will output the available ports to connect to (for example):

```
Opening sequencer port: 128:0 128:1 128:2 128:3
```

4. In a raveloxmidi config file, add the option:

```alsa.output_device = hw:1,0,0```

The device name will vary depending on the setup.

5. Run raveloxmidi with the config file. In debug mode, the debug output should show lines like:

```
[1534193901] DEBUG: raveloxmidi_alsa_init: ret=0 Success
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
```
6. Determine the port number for hw:1,0,0 using aconnect

```aconnect -l```

This will show output like:
```
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 16: 'Ensoniq AudioPCI' [type=kernel,card=0]
0 'ES1371 '
client 20: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
```

This shows that ```hw:1,0,0``` is port ```20:0```

7. Connected the port to timidty:

```aconnect 20:0 128:0```

8. On the remote machine, make a connection to raveloxmidi. I have tested this with OS X.
9. (For example) In Logic Pro X, create a new external MIDI track and use the raveloxmidi connection.
10. Using the keyboard GUI in Logic Pro X, tap a few notes. The notes are played through Timidity.


For input support:

1. Repeat steps 1 and 2 above if the module isn't loaded.

2. In a raveloxmidi config file, add the option:

```alsa.input_device = hw:1,1,0```

The device name will vary depending on the setup but it MUST be different from the device configuired as the output device.

3. Run raveloxmidi with the config file. In debug mode, the debug output should show lines like:
```
[1534193901] DEBUG: raveloxmidi_alsa_init: ret=0 Success
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
[1534193901] DEBUG: rawmidi: handle="hw:1,1,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
```
4. Determine the port number for ```hw:1,1,0``` using aconnect

```aconnect -l``` will show output like:
```
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 16: 'Ensoniq AudioPCI' [type=kernel,card=0]
0 'ES1371 '
client 20: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
client 21: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
```
This shows that ```hw:1,1,0``` is port ```21:0```

5. On the remote machine make a connection raveloxmidi.
6. Run your favourite music making software that will make MIDI connections.
7. On the local machine, Using aplaymidi, take a .mid file and run:

```aplaymidi -p 21:0 name-of-midi-file.mid```

The MIDI events should be processed through the remote software.
131 changes: 15 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The reason for writing this was to generate note events from a Raspberry Pi to s

Thanks to feedback from a couple of users, I've also tested this with rtpMIDI on Windows talking to FL Studio 11.

The build will auto-detect ALSA and build rawmidi support. See below for ALSA requirements. Thanks to Daniel Collins (malacalypse) for being the guinea pig for this.
The build will auto-detect ALSA and build rawmidi support. Please read **FAQ.md** for ALSA requirements. Thanks to Daniel Collins (malacalypse) for being the guinea pig for this.

Except for the Avahi code, it's all mine but I have leaned heavily on the following references:

Expand All @@ -18,6 +18,7 @@ Except for the Avahi code, it's all mine but I have leaned heavily on the follow
Note: Where possible, I've tried to use RTP MIDI to mean the protocol and rtpMIDI to mean the software written by Tobias Erichsen. Some mistakes may be present but,
in most cases, I am referring to the protocol

Some Apple documentation is available at https://developer.apple.com/library/archive/documentation/Audio/Conceptual/MIDINetworkDriverProtocol/MIDI/MIDI.html
I'm doing this purely for fun and don't expect anyone else to use
it but I'm happy to accept suggestions if you ever come across
this code.
Expand Down Expand Up @@ -85,7 +86,7 @@ For debugging, you can run ```raveloxmidi -N -d``` to keep raveloxmidi in the fo
```
network.bind_address
IP address that raveloxmidi listens on. This can be an IPv4 or IPv6 address.
Default is 0.0.0.0 ( meaning all interfaces ). IPv6 equivalent is ::
Default is 0.0.0.0 ( meaning all IPv4 interfaces ). IPv6 equivalent is ::
network.control.port
Main RTP MIDI listening port for new connections and shutdowns.
Used in the zeroconf definition for the RTP MIDI service.
Expand All @@ -96,15 +97,25 @@ network.data.port
network.local.port
Local listening port for accepting MIDI events.
Default is 5006.
service.ipv4
Indicate whether Avahi service should use IPv4 addresses. Default is yes.
service.ipv6
Indicate whether Avahi service should use IPv6 addressed. Default is no.
network.max_connections
Maximum number of incoming connections that can be stored.
Default is 8.
service.name
Name used in the zeroconf definition for the RTP MIDI service.
Default is 'raveloxmidi'.
remote.connect
Name of remote service to connect to.
client.name
Name to use when connecting to remote service. If not defined, service.name will be used.
network.socket_timeout
Polling timeout for the listening sockets.
Default is 30 seconds.
discover.timeout
Length of time in seconds to wait for new remote services to be seen. Default is 5 seconds.
run_as_daemon
Specifies that raveloxmidi should run in the background.
Default is yes.
Expand All @@ -129,6 +140,8 @@ inbound_midi
file_mode
File permissions on the inbound_midi file if it needs to be created. Specify as Unix octal permissions.
Default is 0640.
sync.interval
Interval in seconds between SYNC commands for timing purposes. Default is 60s.
```

If ALSA is detected, the following options are also available:
Expand All @@ -142,117 +155,3 @@ alsa.input_buffer_size
Size of the buffer to use for reading data from the input device.
Default is 4096. Maximum is 65535.
```

## ALSA Support

The autotools configure script will automatically detect the presence of ALSA libraries and will build the code for support.
raveloxmidi uses the rawmidi interface so the snd-virmidi module must be loaded.

The following steps can be taken to test everything is working:

1. Ensure the snd-virmidi module is loaded.

```modprobe snd-virmidi```

2. Verify the device names

```sudo amidi -l``` will give output like
```
Dir Device Name
IO hw:0,0 ES1371
IO hw:1,0 Virtual Raw MIDI (16 subdevices)
IO hw:1,1 Virtual Raw MIDI (16 subdevices)
IO hw:1,2 Virtual Raw MIDI (16 subdevices)
IO hw:1,3 Virtual Raw MIDI (16 subdevices)
```

3. Install timidity and run it with the ALSA interface

```timidity -iA``` will output the available ports to connect to (for example):

```
Opening sequencer port: 128:0 128:1 128:2 128:3
```

4. In a raveloxmidi config file, add the option:

```alsa.output_device = hw:1,0,0```

The device name will vary depending on the setup.

5. Run raveloxmidi with the config file. In debug mode, the debug output should show lines like:

```
[1534193901] DEBUG: raveloxmidi_alsa_init: ret=0 Success
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
```
6. Determine the port number for hw:1,0,0 using aconnect

```aconnect -l```

This will show output like:
```
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 16: 'Ensoniq AudioPCI' [type=kernel,card=0]
0 'ES1371 '
client 20: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
```

This shows that ```hw:1,0,0``` is port ```20:0```

7. Connected the port to timidty:

```aconnect 20:0 128:0```

8. On the remote machine, make a connection to raveloxmidi. I have tested this with OS X.
9. (For example) In Logic Pro X, create a new external MIDI track and use the raveloxmidi connection.
10. Using the keyboard GUI in Logic Pro X, tap a few notes. The notes are played through Timidity.


For input support:

1. Repeat steps 1 and 2 above if the module isn't loaded.

2. In a raveloxmidi config file, add the option:

```alsa.input_device = hw:1,1,0```

The device name will vary depending on the setup but it MUST be different from the device configuired as the output device.

3. Run raveloxmidi with the config file. In debug mode, the debug output should show lines like:
```
[1534193901] DEBUG: raveloxmidi_alsa_init: ret=0 Success
[1534193901] DEBUG: rawmidi: handle="hw:1,0,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
[1534193901] DEBUG: rawmidi: handle="hw:1,1,0" hw_id="VirMidi" hw_driver_name="Virtual Raw MIDI" flags=7 card=1 device=0
```
4. Determine the port number for ```hw:1,1,0``` using aconnect

```aconnect -l``` will show output like:
```
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 16: 'Ensoniq AudioPCI' [type=kernel,card=0]
0 'ES1371 '
client 20: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
client 21: 'Virtual Raw MIDI 1-0' [type=kernel,card=1]
0 'VirMIDI 1-0 '
```
This shows that ```hw:1,1,0``` is port ```21:0```

5. On the remote machine make a connection raveloxmidi.
6. Run your favourite music making software that will make MIDI connections.
7. On the local machine, Using aplaymidi, take a .mid file and run:

```aplaymidi -p 21:0 name-of-midi-file.mid```

The MIDI events should be processed through the remote software.
4 changes: 2 additions & 2 deletions python/note_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
s.connect( connect_tuple )

# Note ON
bytes = struct.pack( "BBBB", 0xaa, 0x96, 0x3c, 0x7f )
bytes = struct.pack( "BBBB", 0xaa, 0x90, 0x30, 0x40 )
s.send( bytes )

time.sleep( 0.25 );

# Note OFF
bytes = struct.pack( "BBBB", 0xaa, 0x86, 0x3c, 0x7f )
bytes = struct.pack( "BBBB", 0xaa, 0x80, 0x30, 0x40 )
s.send( bytes )

s.close()
1 change: 1 addition & 0 deletions raveloxmidi/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -x
rm -f Makefile

aclocal

autoconf

autoheader
Expand Down
10 changes: 7 additions & 3 deletions raveloxmidi/configure.ac
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
AC_INIT()
AC_INIT([raveloxmidi],[0.7.0])
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE(raveloxmidi, 0.6.2)
AM_INIT_AUTOMAKE

AC_CONFIG_HEADERS([config.h])

AC_GNU_SOURCE
Expand All @@ -12,7 +13,6 @@ AC_PROG_INSTALL

AC_SYS_LARGEFILE


PKG_PROG_PKG_CONFIG

PKG_CHECK_MODULES(AVAHI, avahi-client )
Expand All @@ -38,4 +38,8 @@ then
AC_SUBST(DEB_ARCH)
AC_OUTPUT( DEBIAN/control pkgscripts/build_deb )
fi

COPYRIGHT_YEAR="`date +'%Y'`"
AC_SUBST(COPYRIGHT_YEAR)

AC_OUTPUT(Makefile src/Makefile man/Makefile man/raveloxmidi.1 raveloxmidi.spec)
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef CMD_END_HANDLER_H
#define CMD_END_HANDLER_H
#ifndef APPLEMIDI_BY_H
#define APPLEMIDI_BY_H

net_response_t * cmd_end_handler( void *data );
net_response_t * applemidi_by_responder( void *data );

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef CMD_feedback_HANDLER_H
#define CMD_feedback_HANDLER_H
#ifndef APPLEMIDI_FEEDBACK_H
#define APPLEMIDI_FEEDBACK_H

net_response_t * cmd_feedback_handler( void *data );
net_response_t *cmd_feedback_create( uint32_t ssrc, uint16_t rtp_seq );
net_response_t * applemidi_feedback_responder( void *data );
net_response_t * applemidi_feedback_create( uint32_t ssrc, uint16_t rtp_seq );

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef CMD_INV_HANDLER_H
#define CMD_INV_HANDLER_H
#ifndef APPLEMIDI_INV_H
#define APPLEMIDI_INV_H

net_response_t * cmd_inv_handler( char *ip_address, uint16_t port, void *data );
net_response_t * applemidi_inv_responder( char *ip_address, uint16_t port, void *data );

#endif
Loading

0 comments on commit 4192cd7

Please sign in to comment.