App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro.pm  view on Meta::CPAN

sub import {
    # Add private library.
    my $lib = CP->privlib;
    for ( @INC ) {
	return if $_ eq $lib;
    }
    unshift( @INC, $lib );
}

sub ::run {
    binmode(STDERR, ':utf8');
    binmode(STDOUT, ':utf8');
    $options = app_setup( "ChordPro", $VERSION );
    $options->{trace}   = 1 if $options->{debug};
    $options->{verbose} = 1 if $options->{trace};
    $options->{verbose} = 9 if $options->{debug};
    main();
}

sub main {
    my ($opts) = @_;
    $options = { %$options, %$opts } if $opts;

lib/ChordPro.pm  view on Meta::CPAN

    # Call backend to produce output.
    $res = $pkg->generate_songbook($s);
    return $res if $options->{output} eq '*';

  WRITE_OUTPUT:
    # Some backends write output themselves, others return an
    # array of lines to be written.
    if ( $res && @$res > 0 ) {
        if ( $of && $of ne "-" ) {
            open( my $fd, '>', $of );
	    binmode( $fd, ":utf8" );
	    push( @$res, '' ) unless $res->[-1] eq '';
	    print { $fd } ( join( "\n", @$res ) );
	    close($fd);
        }
	else {
	    binmode( STDOUT, ":utf8" );
	    push( @$res, '' ) unless $res->[-1] eq '';
	    print( join( "\n", @$res ) );
	}
	# Don't close STDOUT!
    }
}

sub ::dump {
    use ChordPro::Dumper;
    ddp(@_);

lib/ChordPro.pm  view on Meta::CPAN


    # Plug in command-line options.
    @{$options}{keys %$clo} = values %$clo;
    $::options = $options;
    # warn(::dump($options), "\n") if $options->{debug};

    if ( $tmplcfg ) {
	use File::Copy;
	my $cfg = File::Spec->catfile( CP->findresdirs("config")->[-1],
				       "config.tmpl" );
	binmode STDOUT => ':raw';
	copy( $cfg, \*STDOUT );
	exit 0;
    }
    if ( $defcfg || $fincfg || $deltacfg ) {
	print ChordPro::Config::config_final( default => $defcfg,
					      delta   => $deltacfg );
	exit 0;
    }

    if ( $about ) {

lib/ChordPro/Chords/Parser.pm  view on Meta::CPAN

sub is_chord      ( $self ) { 0 };
sub is_annotation ( $self ) { 0 };
sub has_diagram   ( $self ) { 0 };

################ Testing ################

package main;

unless ( caller ) {
    select(STDERR);
    binmode(STDERR, ':utf8');
    $::config = { settings => { chordnames => "strict" } };
    $::options = { verbose => 2 };
    foreach ( @ARGV ) {
	if ( $_ eq '-' ) {
	    $::config = { settings => { chordnames => "relaxed" } };
	    ChordPro::Chords::Parser->reset_parsers("common");
	    next;
	}
	my $p0 = ChordPro::Chords::Parser->default;
	my $p1 = ChordPro::Chords::Parser->get_parser("common", 1);

lib/ChordPro/Output/PDF/Writer.pm  view on Meta::CPAN

    }
}

sub finish {
    my ( $self, $file ) = @_;

    if ( $file && $file ne "-" ) {
	$self->{pdf}->saveas($file);
    }
    else {
	binmode(STDOUT);
	print STDOUT ( $self->{pdf}->stringify );
	close(STDOUT);
    }
}

sub init_fonts {
    my ( $self ) = @_;
    my $ps = $self->{ps};
    my $fail;

lib/ChordPro/Song.pm  view on Meta::CPAN

    unless ( $full ) {
	for my $ci ( keys %{$a->{chordsinfo}} ) {
	    $a->{chordsinfo}{$ci} = $a->{chordsinfo}{$ci}->simplify;
	}
    }
    ::dump($a);
}

unless ( caller ) {
    require DDumper;
    binmode STDERR => ':utf8';
    ChordPro::Config::configurator();
    my $s = ChordPro::Song->new;
    $options->{settings}->{transpose} = 0;
    for ( @ARGV ) {
	if ( /^[a-z]/ ) {
	    $options->{settings}->{transcode} = $_;
	    next;
	}
#	DDumper::DDumper( $s->parse_chord($_) );
	my ( undef, $i ) = $s->parse_chord($_);

lib/ChordPro/Testing.pm  view on Meta::CPAN


use strict;
use warnings;
use utf8;
use Carp;

use FindBin;
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../lib/ChordPro/lib";

binmode STDOUT => ':utf8';
binmode STDERR => ':utf8';

package ChordPro::Testing;

use parent 'Exporter';
our @EXPORT = qw( $config );

use Test::More ();

use ChordPro::Config;
use ChordPro::Paths;

lib/ChordPro/lib/SVGPDF/FontManager.pm  view on Meta::CPAN

		      lc($2) eq "opentype" ? ".otf" :
		      '';
		}
		elsif ( $opts->{_filesource} =~ /\.(\w+)$/ ) {
		    $sfx = $2;
		}
		# No (or unknown) format, skip.
		next unless $sfx;

		my ($fh,$fn) = tempfile( "${td}SVGXXXX", SUFFIX => $sfx );
		binmode( $fh => ':raw' );
		print $fh $data;
		close($fh);
		my $font = eval { $svg->pdf->font($fn) };
		croak($@) if $@;
		my $f = $fc->{$key} =
		  { font => $font,
		    src => $opts->{_filesource} };
		#warn("SRC: ", $opts->{_filesource}, "\n");
		return ( $f->{font},
			 $style->{'font-size'} || 12,

lib/ChordPro/lib/SVGPDF/FontManager.pm  view on Meta::CPAN

		if ( $src =~ /\bformat\((["'])(.*?)\1\)/ ) {
		    $sfx =
		      lc($2) eq "truetype" ? ".ttf" :
		      lc($2) eq "opentype" ? ".otf" :
		      '';
		}
		# No (or unknown) format, skip.
		next unless $sfx;

		my ($fh,$fn) = tempfile( "${td}SVGXXXX", SUFFIX => $sfx );
		binmode( $fh => ':raw' );
		print $fh decode_base64($data);
		close($fh);
		my $font = eval { $svg->pdf->font($fn) };
		croak($@) if $@;
		my $f = $fc->{$key} =
		  { font => $font,
		    src => 'data' };
		return ( $f->{font},
			 $style->{'font-size'} || 12,
			 $f->{src} );

lib/ChordPro/lib/SVGPDF/Image.pm  view on Meta::CPAN

	$format = "pnm"  if $format =~ /^x[bp]m$/; # bonus
	$format = "tiff" if $format eq "tif";

	# Make the image. Silence missing library warnings.
	my $fh;
	# Also, do not use the fast IPL module, it cannot read from scalar.
	if ( $format eq "tiff" ) {
	    # TIFF can't read from scalar file handle.
	    use File::Temp;
	    ( my $fd, $fh ) = File::Temp::tempfile( UNLINK => 1 );
	    binmode $fd => ':raw';
	    print $fd $data;
	    close($fd);
	    # Yes, trickery... $fh is now a file name, not a handle.
	}
	else {
	    open( $fh, '<:raw', \$data );
	}
	$img = $self->root->pdf->image( $fh, format => $format,
					silent => 1, nouseIPL => 1 );
    }

script/wxchordpro.pl  view on Meta::CPAN

# Last Modified On: Thu Dec 12 07:57:36 2024
# Update Count    : 336
# Status          : Unknown, Use with caution!

################ Common stuff ################

use strict;
use warnings;

use utf8;
binmode(STDERR, ':utf8');
binmode(STDOUT, ':utf8');

use FindBin;
use lib "$FindBin::Bin/../lib";

use ChordPro;
use ChordPro::Paths;
CP->pathprepend( "$FindBin::Bin", "$FindBin::Bin/.." );

# Package name.
my $my_package = 'ChordPro';



( run in 0.431 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )