Show
Ignore:
Timestamp:
10/26/08 01:10:54 (5 years ago)
Author:
bonar
Message:

lang/perl/Music-AutoPhrase?: add NoteSelector::Simple, some bugfix

Location:
lang/perl/Music-AutoPhrase/trunk
Files:
3 added
5 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Music-AutoPhrase/trunk/MANIFEST

    r21910 r22121  
    44README 
    55lib/Music/AutoPhrase.pm 
     6lib/Music/AutoPhrase/Track.pm 
     7lib/Music/AutoPhrase/BeatPattern.pm 
     8lib/Music/AutoPhrase/NoteSelector.pm 
     9lib/Music/AutoPhrase/Note.pm 
     10lib/Music/AutoPhrase/NoteSelector/Simple.pm 
    611lib/Music/AutoPhrase/Channel.pm 
    7 lib/Music/AutoPhrase/Track.pm 
    812lib/Music/AutoPhrase/Code.pm 
    9 lib/Music/AutoPhrase/BeatPattern.pm 
     13lib/Music/AutoPhrase/Constants.pm 
    1014t/00_load.t 
    1115t/10_code.t 
     16t/10_constants.t 
    1217t/11_beatpattern.t 
     18t/12_channel.t 
     19t/13_selector_base.t 
     20t/14_note.t 
     21t/30_selector_simple.t 
     22 
  • lang/perl/Music-AutoPhrase/trunk/lib/Music/AutoPhrase.pm

    r21910 r22121  
    66our $VERSION = '0.01'; 
    77 
     8=head1 NAME 
     9 
     10Music::AutoPhrase - library for "code-base" music composition 
     11 
     12=head1 SYNOPSIS 
     13 
     14=head1 DESCRIPTION 
     15 
     16=cut 
     17 
    8181; 
    919 
  • lang/perl/Music-AutoPhrase/trunk/lib/Music/AutoPhrase/BeatPattern.pm

    r22091 r22121  
    8181    foreach $char (@$beat_array) { 
    8282        if ($is_first) { 
     83            push @cnt_array, $char; 
    8384            $is_first = 0; 
    8485            next; 
     
    9495    } 
    9596    push @dur_array, ($dur + 1) if $dur; 
    96     push @cnt_array, $char if $dur; 
     97    push @cnt_array, $char if $dur && defined $char; 
    9798 
    9899    # push last bit 
    99100    if ($beat_array->[-1] =~ /$on_regexp/) { 
    100101        push @dur_array, 1; 
    101         push @cnt_array, $char; 
     102        push @cnt_array, $char if defined $char; 
    102103    } 
    103104     
  • lang/perl/Music-AutoPhrase/trunk/lib/Music/AutoPhrase/Note.pm

    r22091 r22121  
    2020    is_valid_note_num 
    2121    is_valid_duration 
     22    note_uniq 
    2223/; 
    2324 
     
    4546    return 1 if $duration > 0 && $duration <= BEAT_LENGTH; 
    4647    return; 
     48} 
     49 
     50sub note_uniq { 
     51    my @notes = @_; 
     52 
     53    my (@buff, %seen); 
     54    foreach my $note (@notes) { 
     55        my $str = $note->as_string(); 
     56        next if defined $seen{$str}; 
     57        $seen{$str} = 1; 
     58 
     59        push @buff, $note; 
     60    } 
     61    return @buff; 
    4762} 
    4863 
  • lang/perl/Music-AutoPhrase/trunk/lib/Music/AutoPhrase/NoteSelector.pm

    r22091 r22121  
    1717 
    1818sub extract { 
    19     my ($self, $codes, $bp) = @_; 
     19    my ($self, $codes, $octav_range, $bp) = @_; 
    2020 
    2121    if (ref($codes) ne 'ARRAY') { 
     
    3737        my $count = shift @count; 
    3838 
    39         push @notes, $self->pickup($code, $dur, $count); 
     39        push @notes, [$self->select_note( 
     40            $code, $octav_range, $dur, $count)]; 
    4041        $cursor += $dur; 
    4142    } 
     
    4344} 
    4445 
     46sub pickup { 
     47    die "you must define pickup() in your subclass"; 
     48} 
    4549 
    46501;