--- /dev/null
+#include <fstream.h>
+#include "flower-debug.hh"
+#include "dstream.hh"
+
+bool flower_check_debug=false;
+ofstream null_device ( "/dev/null");
+Dstream default_flower_stream(&null_device ,"/dev/null");
+Dstream *flower_dstream = &default_flower_stream;
+
+/**
+ Set the debugging output. Will not delete/swallow argument.
+ */
+void set_flower_debug(Dstream&ds, bool b)
+{
+ flower_check_debug = b;
+ flower_dstream = &ds;
+}
+
--- /dev/null
+/*
+ flower-debug.hh -- declare
+
+ source file of the Flower Library
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef FLOWER_DEBUG_HH
+#define FLOWER_DEBUG_HH
+
+#include "dstream.hh"
+
+extern Dstream *flower_dstream;
+extern bool flower_check_debug;
+#ifdef NPRINT
+#define fdebug if ( 0 ) *flower_dstream
+#else
+#define fdebug if (flower_check_debug) \
+ flower_dstream->identify_as(__PRETTY_FUNCTION__)
+#endif
+void set_flower_debug(Dstream&ds, bool);
+
+#endif // FLOWER_DEBUG_HH
void tighten();
// assignment.
- void set( Byte const* byte_c_l, int length_i );
+ void set( Byte const* byte_C, int length_i );
- void set( char const* ch_c_l );
+ void set( char const* ch_C );
/// concatenation.
- void append( Byte const* byte_c_l, int length_i );
+ void append( Byte const* byte_C, int length_i );
- void operator += ( char const* ch_c_l );
+ void operator += ( char const* ch_C );
- char const* ch_c_l() const;
+ char const* ch_C() const;
char* ch_l();
- Byte const* byte_c_l() const;
+ Byte const* byte_C() const;
// idem, non const
Byte* byte_l();
~String_handle();
String_handle(String_handle const & src);
- Byte const* byte_c_l() const;
- char const* ch_c_l() const;
+ Byte const* byte_C() const;
+ char const* ch_C() const;
Byte* byte_l();
char* ch_l();
bool is_binary_bo()const;
Byte operator[](int j) const;
/** Access elements. WARNING: NOT SAFE
- don't use this for loops. Use byte_c_l()
+ don't use this for loops. Use byte_C()
*/
Byte &operator[](int j);
- void append( Byte const* byte_c_l, int length_i );
- void set( Byte const* byte_c_l, int length_i );
+ void append( Byte const* byte_C, int length_i );
+ void set( Byte const* byte_C, int length_i );
void operator = (char const *p);
void trunc(int j);
int length_i() const;
/// String s = "abc";
String( char const* source );
- String( Byte const* byte_c_l, int length_i );
+ String( Byte const* byte_C, int length_i );
/// "ccccc"
String( char c, int n = 1 );
/// return a "new"-ed copy of contents
Byte* copy_byte_p() const; // return a "new"-ed copy of contents
- char const* ch_c_l() const;
- Byte const* byte_c_l() const;
+ char const* ch_C() const;
+ Byte const* byte_C() const;
char* ch_l();
Byte* byte_l();
- /// deprecated; use ch_c_l()
- operator char const* () const { return ch_c_l(); }
+ /// deprecated; use ch_C()
+ operator char const* () const { return ch_C(); }
String &operator =( String const & source );
class Dstream;
class String;
-void set_matrix_debug(Dstream&ds);
/** a row of numbers.
a vector. Storage is handled in Array, Vector only does the mathematics.
--- /dev/null
+#include "flower-debug.hh"
+#include "matrix.hh"
+
+
+Matrix::operator String() const
+{
+ String s;
+#ifndef NPRINT
+ s="matrix {\n";
+ for (int i=0; i< rows(); i++){
+ for (int j = 0; j < cols(); j++) {
+ s+= String(dat->elem(i,j), "%6f ");
+ }
+ s+="\n";
+ }
+ s+="}\n";
+#endif
+ return s;
+}
+
+
+void
+Matrix::print() const
+{
+#ifndef NPRINT
+ fdebug << *this;
+#endif
+}
+
+Vector::operator String() const
+{
+ String s;
+#ifndef NPRINT
+ s="vector [";
+ for (int i=0; i < dim(); i++) {
+ s += String(dat[i], "%6f") + String(' ');
+ }
+ s+="]";
+#endif
+ return s;
+}
+
+
+void
+Vector::print() const
+{
+#ifndef NDEBUG
+ fdebug << *this<<'\n';
+#endif
+}
*/
#include <stdio.h>
#include "path.hh"
+#include "flower-debug.hh"
#ifndef PATHSEP
#define PATHSEP '/'
in any other added path, in this order.
*/
String
-File_path::find(String nm)
+File_path::find(String nm)const
+
{
- for (int i=0; i < size(); i++) {
+ fdebug << "looking for " << nm ;
+ for (int i=0; i < size(); i++) {
+
String path = (*this)[i];
path+= "/"+nm;
-
+ fdebug << path << "? ";
FILE *f = fopen(path, "r"); // ugh!
if (f) {
+ fdebug << "found\n";
fclose(f);
return path;
}
}
- return "";
+ fdebug << "\n";
+ return "";
}
int conv = false;
if (len()) {
long l =0;
- conv = sscanf(strh_.ch_c_l(), "%ld", &l);
+ conv = sscanf(strh_.ch_C(), "%ld", &l);
}
return len() && conv;
}
String_convert::bin2hex_str( String bin_str )
{
String str;
- Byte const* byte_c_l = bin_str.byte_c_l();
+ Byte const* byte_C = bin_str.byte_C();
for ( int i = 0; i < bin_str.length_i(); i++ ) {
- str += (char)nibble2hex_byte( *byte_c_l >> 4 );
- str += (char)nibble2hex_byte( *byte_c_l++ );
+ str += (char)nibble2hex_byte( *byte_C >> 4 );
+ str += (char)nibble2hex_byte( *byte_C++ );
}
return str;
}
return 0;
long l = 0;
- int conv = sscanf( dec_str.ch_c_l(), "%ld", &l );
+ int conv = sscanf( dec_str.ch_C(), "%ld", &l );
assert( conv );
return (int)l;
if ( !dec_str.length_i() )
return 0;
double d = 0;
- int conv = sscanf( dec_str.ch_c_l(), "%lf", &d );
+ int conv = sscanf( dec_str.ch_C(), "%lf", &d );
assert( conv );
return d;
}
hex_str = "0" + hex_str;
bin_str_r = "";
- Byte const* byte_c_l= hex_str.byte_c_l();
+ Byte const* byte_C= hex_str.byte_C();
int i = 0;
while ( i < hex_str.length_i() ) {
- int high_i = hex2nibble_i( *byte_c_l++ );
- int low_i = hex2nibble_i( *byte_c_l++ );
+ int high_i = hex2nibble_i( *byte_C++ );
+ int low_i = hex2nibble_i( *byte_C++ );
if ( high_i < 0 || low_i < 0 )
return 1; // illegal char
bin_str_r += String( (char)( high_i << 4 | low_i ), 1 );
Byte*
String::copy_byte_p() const
{
- Byte const* src = strh_.byte_c_l();
+ Byte const* src = strh_.byte_C();
Byte* dest = new Byte[strh_.length_i() + 1];
memcpy( dest, src, strh_.length_i() + 1 );
return dest;
String::print_on(ostream& os) const
{
if (!strh_.is_binary_bo())
- os << ch_c_l();
+ os << ch_C();
else
for ( int i = 0; i < length_i(); i++ )
os << (Byte)(*this)[ i ];
void
String::append(String s)
{
- strh_.append( s.byte_c_l(), s.length_i() );
+ strh_.append( s.byte_C(), s.length_i() );
}
void
String::operator +=(String s)
}
Byte const*
-String::byte_c_l() const
+String::byte_C() const
{
- return strh_.byte_c_l();
+ return strh_.byte_C();
}
char const*
-String::ch_c_l() const
+String::ch_C() const
{
- return strh_.ch_c_l();
+ return strh_.ch_C();
}
Byte*
int
String::compare_i(String const& s1, String const& s2 )
{
- Byte const* p1 = s1.byte_c_l();
- Byte const* p2 = s2.byte_c_l();
+ Byte const* p1 = s1.byte_C();
+ Byte const* p2 = s2.byte_C();
if ( p1 == p2 )
return 0;
if ( !length_i() )
return -1;
- char const* me = strh_.ch_c_l();
+ char const* me = strh_.ch_C();
char const* p = memrchr(me, length_i(), c );
if ( p )
return p - me;
int
String::index_i(char c ) const
{
- char const* me = strh_.ch_c_l();
+ char const* me = strh_.ch_C();
char const* p = (char const *) memchr( me,c, length_i());
if ( p )
return p - me;
int
String::index_i( String searchfor ) const
{
- char const* me = strh_.ch_c_l();
+ char const* me = strh_.ch_C();
char const* p = (char const *) memmem(
- me, length_i(), searchfor.ch_c_l(), searchfor.length_i());
+ me, length_i(), searchfor.ch_C(), searchfor.length_i());
if ( p )
return p - me;
if ( !n )
return -1;
- void const * me_l = (void const *) strh_.ch_c_l();
+ void const * me_l = (void const *) strh_.ch_C();
for (int i=0; i < set.length_i(); i++) {
char * found=(char*) memchr(me_l, set[i], n );
if (found) {
if ( n < 1)
return "";
- return String( strh_.byte_c_l() + length_i() - n, n );
+ return String( strh_.byte_C() + length_i() - n, n );
}
if ( ( n > length_i() ) || ( index_i + n > length_i() ) )
n = length_i() - index_i;
- return String( byte_c_l() + index_i, n );
+ return String( byte_C() + index_i, n );
}
\f
String
%
global=\music{\meter {4/4}
\grouping {2*2}
- \key {bes es as}}
+ \key {bes es as}
+
+}
dux = \music {
- \clef \violin
+ \clef \violin\octave{1}
\duration { \last }
-
- r8-"dux" \stem{-1}
+ \stem{-1}
+ r8-"dux"
[c'16 b] [c'8 g] [as c'16 b] [c'8 d'] |
[g c'16 b] [c'8 d'] [f16 g] as4 [g16 f] |
[es c' b a] [ g f es d] [c8 es' d' c'] |
}
comes = \music {
- \octave {'}
- r1 \stem{1}
- |
+ \octave {2}\stem{1}
+ r1 |
r1 |
r8-"comes" [g16 fis] [g8 c] [es g16 f] [g8 a]|
[d8 g16 fis] [g8 a] [c16 d] es4 [d16 c] |
- [`bes8 es16 d] [es8 `g8] [`as f16 es] [f8 `a]
- [`bes8 g16 f] [g8 `b] [c8 d16 es] f4( |
- [) f8 es16 d] [c16 `bes `as `g] [`f8 as g f]
- [es d es f] [`b c d `b] |
+ ['bes8 es16 d] [es8 'g8] ['as f16 es] [f8 'a]
+ ['bes8 g16 f] [g8 'b] [c8 d16 es] f4( |
+ [) f8 es16 d] [c16 'bes 'as 'g] ['f8 as g f]
+ [es d es f] ['b c d 'b] |
}
bassdux = \music {
\clef \bass
- \octave { }
+ \octave {1}
r1 |
r |
r |
int dots;
int balltype;
-
+
+ /// rests can be translated up and down.
+ int pos_i_;
/* *************** */
- Rest(int dur,int dots);
+ Rest(Duration);
void do_print()const;
NAME_MEMBERS(Rest);
Molecule* brew_molecule_p()const;
#include "lgetopt.hh"
#include "moment.hh"
+#include "duration-convert.hh"
#include "duration.hh"
-#include "input-file.hh"
#include "source-file.hh"
#include "source.hh"
#define qtor if ( level_ver >= QUIET_ver ) *monitor_p_g
#endif
-extern Source* source_l_g;
-void message( String message_str, char const* context_ch_c_l );
-void warning( String message_str, char const* context_ch_c_l );
-void error( String message_str, char const* context_ch_c_l );
+extern Sources* source_l_g;
+void message( String message_str, char const* context_ch_C );
+void warning( String message_str, char const* context_ch_C );
+void error( String message_str, char const* context_ch_C );
String mi2mu_version_str();