note.h

来自「Nokia手机语音管理程序」· C头文件 代码 · 共 85 行

H
85
字号
#ifndef NOTE_H
#define NOTE_H
#pragma once

#include "Time.h"

#include <list>

using std::list;

// +-------------------------------------------------------------
// |
// | Class           : ParserException
// | Descripci髇     : 
// | 
// +-------------------------------------------------------------
class ParserException
{
public:
  ParserException( const char* description, const char* string );
  const CString& GetDescription();
  const CString& GetNoteString();
  const char* GetNextNote();

private:
  CString description_;
  CString noteString_;
  const char* nextNote_;
};

// +-------------------------------------------------------------
// |
// | Class           : Note
// | Descripci髇     : 
// | 
// +-------------------------------------------------------------
class Note : public CObject
{
  DECLARE_SERIAL(Note)

public:
  enum Tone { Silence, ToneC, ToneD, ToneE, ToneF, ToneG, ToneA, ToneB };  

  Note();
  Note(Tone tone, int duration, int octave, bool dot, bool sharp);
	Note(const Note& other);
	virtual ~Note();

  CString     GetString() const;
  const char* ParseString(const char* string);

  void GetMIDINote(int& duration, int& note) const;

  Tone  GetTone()     { return tone_; }
  int   GetDuration() { return duration_; }
  bool  HasDot()      { return dot_; }
  bool  HasSharp()    { return sharp_; }
  int   GetOctave()   { return octave_; }
  
  virtual void Serialize(CArchive &ar);

  void OctaveUp();
  void OctaveDown();
  void SemitoneUp();
  void SemitoneDown();

  bool CanOctaveUp() const;
  bool CanOctaveDown() const;
  bool CanSemitoneUp() const;
  bool CanSemitoneDown() const;
  
private:
  Tone  tone_;
  int   duration_;
  int   octave_;
  bool  dot_;
  bool  sharp_;

  virtual void AssertValid() const;
  bool IsValid(const char** reason) const;
};

typedef list<Note> NoteSequence;

#endif //NOTE_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?