That's basically it. It will play the given sound file through the PODxt for each program or amp you tell it you want to hear. This can easily be extended to also sample anything else in the PODxt: different effects, different settings for the effects, and so on, using the MIDI CC Reference guide (for example, amp changes are CC #11, stomp box changes are CC #75, modulation changes are CC #58, etc.). I figure I will use this quite a bit as I pick up recording again soon, so I can quickly and easily sample different amps and effects to find the sound I want.
#!/usr/bin/perl
# podxt-soundtest.plx
use strict;
use warnings;
use File::Basename;
use File::Spec::Functions qw(catdir catfile);
use FindBin '$Bin';
use Mac::Errors '$MacError';
use Mac::Glue ':all';
use Mac::Speech;
use Time::HiRes 'sleep';
my $DEBUG = 1;
my $RECORD = 1;
my $SPEECH = 0;
use constant {
CC => 176,
PROGRAM => 192,
AMP_ENABLE => 111,
AMP_SELECT => 11,
};
my @voice = qw(Damien Diane Vicki Victoria);
my $midi_port = 'MidiPipe Input 1';
my $sound_file = shift;
my($sound_name, $sound_dir) = fileparse($sound_file, qr/\..+/);
my($qt_player, $midi_pipe, $sound_studio, $voice, $speech, $recording, $movie, $done);
init();
main_loop();
finish();
sub main_loop {
for my $n (111, 32.. 79) {
doit(program => $n);
}
# blank program
midi({ program => 127 });
for my $n (73.. 100) {
doit(amp => $n);
}
}
sub doit {
my($what, $which) = @_;
get_sound_files();
start_recording();
say($what, $which);
midi({ $what, $which });
play();
stop_recording();
save_recording($what, $which);
}
sub finish {
print "Done.\n";
exit;
}
sub init {
$qt_player = new Mac::Glue 'QuickTime Player';
$midi_pipe = new Mac::Glue 'MidiPipe';
$sound_studio = new Mac::Glue 'Sound Studio' if $RECORD;
if ($SPEECH) {
my $V;
for (@voice) {
last if $V = $Mac::Speech::Voice{$_};
}
$speech = NewSpeechChannel( $V );
}
if ($DEBUG) {
$qt_player->ERRORS(1);
$midi_pipe->ERRORS(1);
$sound_studio->ERRORS(1) if $RECORD;
}
$sound_studio->launch if $RECORD;
my($pipe) = fileparse($0, qr/\..+/);
$midi_pipe->open(catfile($Bin, $pipe . '.mipi'));
$qt_player->activate;
open_sound_file();
# preload voice
if ($SPEECH) {
SpeakText($speech, '');
sleep 0.1 while SpeechBusy();
}
$movie = $qt_player->obj(movie => 1, window => 1);
$done = $movie->prop('done');
}
sub midi {
my($params) = @_;
my $opts = {
toPort => $midi_port
};
if (defined $params->{program}) {
$opts->{withData} = [ PROGRAM, $params->{program} ];
} elsif (defined $params->{amp}) {
$opts->{withData} = [ CC, AMP_ENABLE, 0 ];
$midi_pipe->MIDISend(%$opts);
$opts->{withData} = [ CC, AMP_SELECT, $params->{amp} ];
}
$midi_pipe->MIDISend(%$opts);
}
sub say {
return unless $SPEECH;
my($what, $which) = @_;
my $text = "$what number $which";
print "$text\n";
midi({ program => 127 });
SpeakText($speech, $text);
sleep 0.1 while SpeechBusy();
}
sub play {
$movie->start;
while (1) {
last if $done->get;
sleep 0.5;
}
sleep 1.5;
}
sub get_sound_files {
if ($RECORD) {
$recording = $sound_studio->make(new => 'document');
}
open_sound_file();
}
sub open_sound_file {
$qt_player->obj(file => $sound_file)->open;
}
sub start_recording {
return unless $RECORD;
$recording->record;
}
sub stop_recording {
return unless $RECORD;
$recording->stop;
}
sub save_recording {
return unless $RECORD;
my($what, $which) = @_;
my $dir = catdir($sound_dir, $sound_name . '-samples');
mkdir $dir;
sleep 5;
$recording->save(
in => $recording->obj(file => catfile($dir, "$what-$which.aiff")),
as => enum('AIFF')
);
sleep 5;
$recording->close;
}
Stupid Mac::Glue Tricks: PODxt Sampling 0 Comments More | Login | Reply /