-
Notifications
You must be signed in to change notification settings - Fork 409
/
wav.h
39 lines (32 loc) Β· 861 Bytes
/
wav.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// A simple sound library adapted from Douglas Thain's ([email protected])
// wavfile library for CSE 20211 made available under the
// Creative Commons Attribution license.
// https://creativecommons.org/licenses/by/4.0/
#include <cs50.h>
#include <stdio.h>
#include <inttypes.h>
// Representation of a note
typedef struct note
{
int frequency;
int duration;
}
note;
// Representation of a song
struct song
{
string filename;
note **notes;
size_t capacity;
size_t size;
int duration;
};
typedef struct song *song;
// Adds a note to a song for a given duration (in eighths)
bool note_write(song s, int frequency, int duration);
// Adds a rest to a song for a given duration (in eighths)
bool rest_write(song s, int duration);
// Saves a song to disk
bool song_close(song s);
// Creates a new song
song song_open(string filename);