- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatLib/Pitch.cpp File Reference

`#include "Musimat.h"`

Go to the source code of this file.

## Functions
ostream & | operator<< (ostream &os, Pitch &p)
Bool | isnumeric (char c)
Bool | inRange (char c, char lb, char ub)
istream & | operator>> (istream &is, Pitch &p)

## Function Documentation

Bool inRange | ( | char | c,
|  | char | lb,
|  | char | ub |
| ) |  |  | `[inline]`

Definition at line 35 of file Pitch.cpp.

References Return.

Referenced by operator>>().

    00036 {
    00037         Return c >= lb && c <= ub;
    00038 }

Bool isnumeric | ( | char | c | ) | `[inline]`

Definition at line 30 of file Pitch.cpp.

References Return.

Referenced by operator>>().

    00031 {
    00032         Return c >= '0' && c <= '9';
    00033 }

ostream& operator<< | ( | ostream & | os,
|  | Pitch & | p |
| ) |  |  |

Definition at line 24 of file Pitch.cpp.

References Pitch::print(), and Return.

    00025 {
    00026         os << p.print();
    00027         Return os;
    00028 }

istream& operator>> | ( | istream & | is,
|  | Pitch & | p |
| ) |  |  |

Definition at line 40 of file Pitch.cpp.

References Else, If, inRange(), Pitch::isAccidental(), isnumeric(), Pitch::isPitchClass(), Pitch::m_acc, Pitch::m_oct, Pitch::m_pc, Return, and While.

    00041 {
    00042         //char buf[16];
    00043         //cin >> buf;
    00044         //p = Pitch(buf);
    00045         //Return is;
    00046         char c;
    00047         cin >> c;
    00048         If ((p.m_pc = p.isPitchClass(c)) == -1) {
    00049                 cin.unget();
    00050                 Return is;
    00051         }
    00052
    00053         Integer acc = 0;
    00054         While (cin >> c && ((acc = p.isAccidental(c)) != -3)) {
    00055                 p.m_acc += acc;
    00056         }
    00057
    00058         If (!inRange(c, '0', '9')) {
    00059                 cin.unget();
    00060                 Return is;
    00061         } Else {
    00062                 char buf[16];
    00063                 char* b = buf;
    00064                 Integer cnt = 0;
    00065                 cin.unget();
    00066                 While (!cin.eof() && cin >> c && isnumeric(c) && cnt++ < 16) {
    00067                         char y = cin.eof();
    00068                         *b++ = c;
    00069                 }
    00070                 cin.unget();
    00071                 *b = '\0';
    00072                 p.m_oct = atoi(buf);
    00073         }
    00074         Return is;
    00075 }