lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can I set panning in midi


From: Karl Hammar
Subject: Re: can I set panning in midi
Date: Fri, 6 Sep 2013 17:52:42 +0200 (CEST)

Vaughan McAlley:
> On 6 September 2013 19:06, Karl Hammar <address@hidden> wrote:
> 
> > Vaughan McAlley:
> > > On 6 September 2013 08:50, Karl Hammar <address@hidden> wrote:
> > ...
> > > > > For which purposes do You want to use midi?
> > > >
> > > > Producing exercise sound files for the choir, they basically wants
> > > > mp3's or something similar. I have tried ogg but their systems kind
> > > > of not understands that.
> > > >
> > > > I'd like to have e.g. basses at left, tenors mid left, altos mid right
> > > > and sopranos at right, to make each voice easier to hear and follow.
> > ...
> > > I wrote the attached script for exactly this purpose. It saves mucking
> > > around with anything more sophisticated than a simple MIDI player. The
> > > tracks are distributed evenly across the panning range. Unfortunately
> > > it requires Lua, but Lua is small and the last few times I’ve found it
> > > very easy to install. More detailed instructions are in the script...
> >
> > For some reason it produces a exact copy of the input file:
...
> Oops, it looks like MIDI files produced by LilyPond 2.17 look a bit
> different to what 2.16 produced. This revised version of the script appears
> to work, and spat out the attached MIDI file...

This is exactly what I needed, thank you very much!
It works wery well with 2b_choer.midi file, 4 tracks, but for some
reason it fails with

 http://turkos.aspodata.se/motett/c_saint_saens/4_air.midi

witch have 5 voices, one tenor solo + 4 discant voices.
The tenor starts to the right but moves to the middle at measure 7,
at least with timidity. Looking att the result midi file it seems
panning.lua only set panning i the tenor voice.

I found libmidi-perl, so I made this little program:
///
#!/usr/bin/perl -w

use strict;
use MIDI;

my $one;
foreach $one (@ARGV) {
    my $opus = MIDI::Opus->new({ 'from_file' => $one });
    print "$one:\n";
    $opus->dump({ "dump_tracks" => 1 });
}
///

and testing gives me
$ lua5.2 ~/panning.lua 2b_choer.midi 2.midi

$ ./midi.pl 2.midi | grep -v note_on 
2.midi:
MIDI::Opus->new({
  'format' => 1,
  'ticks'  => 384,
  'tracks' => [   # 5 tracks...

    # Track #0 ...
    MIDI::Track->new({
      'type' => 'MTrk',
      'events' => [  # 5 events.
        ['track_name', 0, 'control track'],
        ['text_event', 0, 'creator: '],
        ['text_event', 0, 'GNU LilyPond 2.17.10          '],
        ['time_signature', 0, 4, 2, 18, 8],
        ['set_tempo', 0, 416666],
      ]
    }),
    
    # Track #1 ...
    MIDI::Track->new({
      'type' => 'MTrk',
      'events' => [  # 162 events.
        ['patch_change', 0, 0, 33],
        ['patch_change', 0, 0, 33],
        ['instrument_name', 0, 'electric bass (finger)'],
        ['control_change', 0, 0, 7, 100],
        ['control_change', 0, 0, 10, 0],
        ['track_name', 0, ':Vs'],
      ]
    }),
    
    # Track #2 ...
    MIDI::Track->new({
      'type' => 'MTrk',
      'events' => [  # 182 events.
        ['patch_change', 0, 1, 33],
        ['patch_change', 0, 1, 33],
        ['instrument_name', 0, 'electric bass (finger)'],
        ['control_change', 0, 1, 7, 100],
        ['control_change', 0, 1, 10, 42],
        ['track_name', 0, ':Va'],
      ]
    }),
    
    # Track #3 ...
    MIDI::Track->new({
      'type' => 'MTrk',
      'events' => [  # 122 events.
        ['patch_change', 4608, 2, 33],
        ['patch_change', 0, 2, 33],
        ['instrument_name', 0, 'electric bass (finger)'],
        ['control_change', 0, 2, 7, 100],
        ['control_change', 0, 2, 10, 85],
        ['track_name', 0, ':Vt'],
      ]
    }),
    
    # Track #4 ...
    MIDI::Track->new({
      'type' => 'MTrk',
      'events' => [  # 146 events.
        ['patch_change', 4608, 3, 33],
        ['patch_change', 0, 3, 33],
        ['instrument_name', 0, 'electric bass (finger)'],
        ['control_change', 0, 3, 7, 100],
        ['control_change', 0, 3, 10, 127],
        ['track_name', 0, ':Vb'],
      ]
    }),
    
  ]
});

So it does it's job.
But for

$ lua ~/panning.lua 4_air.midi 4.midi
$ ./midi.pl 4.midi | grep -v note_on > b
$ ./midi.pl 4_air.midi | grep -v note_on > a
$ diff a b
1c1
< 4_air.midi:
---
> 4.midi:
22c22
<       'events' => [  # 252 events.
---
>       'events' => [  # 253 events.
27a28
>         ['control_change', 0, 0, 10, 0],
$

I.e. only the tenor track is changed. Idéas?

Regards,
/Karl Hammar

-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57





reply via email to

[Prev in Thread] Current Thread [Next in Thread]