The Perl Advent Calendar needs more articles for 2022. Submit your idea today!


Music::PitchNum::German - note name and pitch number roles for BACH


  package MyCleverMozart;
  use Moo;

Then elsewhere:

  use MyCleverMozart;
  my $x = MyCleverMozart->new;

  $x->pitchname(70);      # b'
  $x->pitchname(69);      # a'
  $x->pitchname(72);      # c''
  $x->pitchname(71);      # h'

  $x->pitchnum(q{aes'});  # 68
  $x->pitchnum(q{g'});    # 67
  $x->pitchnum(q{b'});    # 70
  $x->pitchnum(q{a'});    # 69

  $x->pitchname(72, ignore_octave => 1); # c


A Music::PitchNum implementation specifically for BACH, whereby H represents what other systems term B natural and B represents B flat. Otherwise, the implementation is Helmholtz-based, or the one typically seen in lilypond, with accidentals in the Dutch or German style (es, is), and octave indications using , and '.

This module is expected to be used as a Role from some other module; Moo::Role may be informative.


pitchname pitchnumber

Returns the pitch name for the given integer, though will throw an exception if passed something that is not a number.

This method accepts an optional ignore_octave parameter that if true will strip the octave information from the pitch name.

pitchnum pitchname

Returns the pitch number for the given note name, or undef if the note could not be parsed. Note that the parser is quite permissive, see "Known Issues".


Reporting Bugs

Please report any bugs or feature requests to bug-music-pitchnum at, or through the web interface at

Patches might best be applied towards:

Known Issues

The parser is too lax, in that it will parse invalid input such as cses''' as pitch number 48 on account of the leading c.


Music::PitchNum, ly-fu of App::MusicTools



thrig - Jeremy Mates (cpan:JMATES) <jmates at>


Copyright (C) 2014-2016 by Jeremy Mates

This module is free software; you can redistribute it and/or modify it under the Artistic License (2.0).