Wednesday, 28 June 2017

Array

Notes for reading C++ Primer 4/e.

Dynamic Array

value-initialize


In dynamic array, it could only initial w/ default value, not like static array, could initial as different values.
int *pia = new int[10]();  // 10 ints w/ default value 0

const

Notes for reading C++ Primer 4/e.

const Reference

Reference to a constant object.
const int ival = 1024;
const int &refVal = ival;
const int &r = 42;
const int &r2 = r + 3;


const_iterator

for (vector<string>::const_iterator iter = text.begin();
iter != text.end(); ++iter) {
    *iter = " ";  // error: *iter is const
}
vector<int> nums(10);
const vector<int>::iterator cit = nums.begin();
*cit = 1;  // OK
++cit;  // error: cit is const


Pointers & const

Pointers to const

const double pi = 3.14;
double *ptr = &pi;  // error: nonconst pointer
const double *cptr = &pi;  // OK

double dval = 2.99;
cptr = &dval;  // OK

const Pointer

int errNumber = 0;
int *const curErr = &errNumber;
curErr = curErr;  // error: curErr is const

if (*curErr) {
    errorHandler();
    *curErr = 0;  // OK
}

const Pointer Point To A const Object

const double pi = 3.14159;
const double *const pi_ptr = &pi;
pi_ptr is a constant pointer, point to a const double object.


Pointers & Typedefs

typedef string *pstring;
const pstring cstr;
Q: What is cstr?
A: Constant point, point to string.

Tuesday, 27 June 2017

Minor (Aeolian)

大調小調



自然/和聲/旋律小音階


  • Major Scale: 1 2 3 4 5 6 7
  • Nature Minor Scale: 1 2 b3 4 5 b6 b7
  • Harmonic Minor Scale: 1 2 b3 4 5 b6 7
  • Melodic Minor Scale: 1 2 b3 4 5 6 7 1 b7 b6 5 4 b3 2 1

Thursday, 22 June 2017

Secondary Dominant

Learning notes of Secondary Dominant.

Secondary Dominant


什麼是大調小調?



Dominant


  • V -> I

讓 Dominant 更漂亮



  • ii -> V -> I or vii7(b5) -> V7 -> i

用 2-5-1


  • ii -> V -> I -> (Key - whole note) ii -> V -> I -> (Key - whole note) ii -> V -> I -> …

Advanced Reading


Wednesday, 21 June 2017

How to Make Chord Progression

Learning how to make chord progression for a melody.

How to Make Chord Progression

如何幫一個旋律配上和弦?


  • 使用和弦內音的方式來配置

用 C, G7, Dm 和 F



  • 使用和弦內音的方式來配置 並 考慮 ii -> V -> I, I -> IV 等慣用進行

用大調 1-6 級



  • Tonic -> Sub-dominant -> Dominant -> Tonic 的感覺考慮進去
  • normally we use Tonic -> Sub-dominant or Tonic -> Dominant (but it’s more comfortable to use Tonic -> Sub-dominant -> Tonic) (1)
  • normally we use Sub-dominant -> Tonic or Sub-dominant -> Dominant (2)
  • normally we use Dominant -> Tonic (3)
  • 先用 I, IV, V 配置,再用 (3), (2), (1) 修飾

用 Secondary Dominant Chord



  • 每個和弦轉換皆可觀查是否能用

Advanced Reading


Major (Ionian)

Learning from key C.

Triads

  • C: 1-3-5 (1 3 5)
  • Dm: 2-4-6 (1 b3 5)
  • Em: 3-5-7 (1 b3 5)
  • F: 4-6-1 (1 3 5)
  • G: 5-7-2 (1 3 5)
  • Am: 6-1-3 (1 b3 5)
  • Bdim: 7-2-4 (1 b3 b5)

Shape



  • 1st Inversion



  • 2nd Inversion


Seventh Chord

  • CM7: 1-3-5-7 (1 3 5 7)
  • Dm7: 2-4-6-1 (1 b3 5 b7)
  • Em7: 3-5-7-2 (1 b3 5 b7)
  • FM7: 4-6-1-3 (1 3 5 7)
  • G7: 5-7-2-4 (1 3 5 b7)
  • Am7: 6-1-3-5 (1 b3 5 b7)
  • Bm7(b5): 7-2-4-6 (1 b3 b5 b7)

[note]:
  1. Bm is 7-2-#4 and Bm7 is 7-2-#4-6.
  2. Half-diminished seventh: 1 b3 b5 b7
  3. Diminished seventh: 1 b3 b5 bb7
Reference:

External Reading: