Giter Club home page Giter Club logo

etdudomatic's Introduction

use strict;
use warnings;
package Music::Etudomatic;
use Mojo::Base -base;

=head2 NAME

Music::Etudomatic

An offline music sequencer to facilitate the production of chord patterns.


=head2 USAGE

    my $bot = Music::Etudomatic->new(key => 'd', mode => 'major', notes_per_chord => 3 );
    my $sequencer_data = $bot->sequences;
    my $sequence = $bot->sequence_for($pattern);

=head2 TODO

Assumption is that the current output is for lilypond score.

My next steps are to get some test coverage in t/01-basic.t

Implement the sequence_for method

=cut

use Music::Etudomatic::Sequences;

has key => sub { 'c' };
has mode => sub { 'major' };
has notes_per_chord => sub { 3 };

has asc => sub { [ 0 .. $_[0]->notes_per_chord - 1 ] };
has desc => sub {
    my ($self) = @_;
    my @d = @{$self->{asc}};
    unshift @d, pop @d;
    return \@d;
};

my @notes = ( [ 1 => 'c'], [ 2 => 'cis'],
	      [ 3 => 'd'], [ 4 => 'ees'],
	      [ 5 => 'e'],
	      [ 6 => 'f'], [ 7 => 'fis'],
	      [ 8 => 'g'], [ 9 => 'gis'],
	      [ 10 => 'a'], [ 11 => 'bes'],
	      [ 12 => 'b'], );

my @enh = (
    [ 1 => 'bis'],
    [ 4 => 'des'],
    [ 4 => 'dis'],
    [ 7 => 'ges'],
    [ 9 => 'aes'],
    [ 11 => 'ais' ],
);

has note2num => sub {
    return { map { $_->[1] => $_->[0] } ( @notes, @enh ) } # and enharmonics
};

has num2note => sub {
    my %n2n = map { $_->[0] => $_->[1] } ( @notes, ( $_[0]->key =~ /es$/ ? @enh : () ) );
    return \%n2n;
};

has nums => sub { Array::Circular->new(1 .. @notes ) };


has sequences => sub {
    return Music::Etudomatic::Sequences->new(config => $_[0]);
};

1;

etdudomatic's People

Contributors

dr-kd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.