Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Music/Music.cpp@4:afbf3dd71403, 2019-04-06 (annotated)
- Committer:
- joshdavy
- Date:
- Sat Apr 06 11:47:18 2019 +0000
- Revision:
- 4:afbf3dd71403
- Child:
- 5:b9cf407bcc63
Began implemting music playing class
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| joshdavy | 4:afbf3dd71403 | 1 | Music::Music() |
| joshdavy | 4:afbf3dd71403 | 2 | { |
| joshdavy | 4:afbf3dd71403 | 3 | |
| joshdavy | 4:afbf3dd71403 | 4 | } |
| joshdavy | 4:afbf3dd71403 | 5 | Music::~Music() |
| joshdavy | 4:afbf3dd71403 | 6 | { |
| joshdavy | 4:afbf3dd71403 | 7 | |
| joshdavy | 4:afbf3dd71403 | 8 | |
| joshdavy | 4:afbf3dd71403 | 9 | |
| joshdavy | 4:afbf3dd71403 | 10 | } |
| joshdavy | 4:afbf3dd71403 | 11 | Music::init(int * data) |
| joshdavy | 4:afbf3dd71403 | 12 | { |
| joshdavy | 4:afbf3dd71403 | 13 | _data = data; |
| joshdavy | 4:afbf3dd71403 | 14 | speaker.period(0.000016); // Has to >> then 1/sample rate |
| joshdavy | 4:afbf3dd71403 | 15 | speaker.write(0); // until music played stay silent |
| joshdavy | 4:afbf3dd71403 | 16 | _index = 0 |
| joshdavy | 4:afbf3dd71403 | 17 | } |
| joshdavy | 4:afbf3dd71403 | 18 | |
| joshdavy | 4:afbf3dd71403 | 19 | Music::play_next() |
| joshdavy | 4:afbf3dd71403 | 20 | { |
| joshdavy | 4:afbf3dd71403 | 21 | if (_index < NUM_ELEMENTS) { |
| joshdavy | 4:afbf3dd71403 | 22 | speaker.write(*(_data+index)); |
| joshdavy | 4:afbf3dd71403 | 23 | } |
| joshdavy | 4:afbf3dd71403 | 24 | |
| joshdavy | 4:afbf3dd71403 | 25 | |
| joshdavy | 4:afbf3dd71403 | 26 | } |