libsmf

- Main Page
- Data Structures
- Files

- File List
- Globals

smf_private.h
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2007, 2008 Edward Tomasz Napierała <trasz@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * ALTHOUGH THIS SOFTWARE IS MADE OF WIN AND SCIENCE, IT IS PROVIDED BY THE
15 * AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18 * THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28 #ifndef SMF_PRIVATE_H
29 #define SMF_PRIVATE_H
30
31 #include <stdint.h>
32 #include <sys/types.h>
33
34 #include "config.h"
35
36 #define SMF_VERSION PACKAGE_VERSION
37
45 #if defined(__GNUC__)
46 #define ATTRIBUTE_PACKED __attribute__((__packed__))
47 #else
48 #define ATTRIBUTE_PACKED
49 #pragma pack(1)
50 #endif
51
53 struct chunk_header_struct {
54 char id[4];
55 uint32_t length;
56 } ATTRIBUTE_PACKED;
57
59 struct mthd_chunk_struct {
60 struct chunk_header_struct mthd_header;
61 uint16_t format;
62 uint16_t number_of_tracks;
63 uint16_t division;
64 } ATTRIBUTE_PACKED;
65
66 #if (!defined __GNUC__)
67 #pragma pack()
68 #endif
69
70 void smf_track_add_event(smf_track_t *track, smf_event_t *event);
71 void smf_init_tempo(smf_t *smf);
72 void smf_fini_tempo(smf_t *smf);
73 void smf_create_tempo_map_and_compute_seconds(smf_t *smf);
74 void maybe_add_to_tempo_map(smf_event_t *event);
75 void remove_last_tempo_with_pulses(smf_t *smf, int pulses);
76 int smf_event_is_tempo_change_or_time_signature(const smf_event_t *event) WARN_UNUSED_RESULT;
77 int smf_event_length_is_valid(const smf_event_t *event) WARN_UNUSED_RESULT;
78 int is_status_byte(const unsigned char status) WARN_UNUSED_RESULT;
79
80 #endif /* SMF_PRIVATE_H */
81
mthd_chunk_struct
SMF chunk, used only by smf_load.c and smf_save.c.
Definition: smf_private.h:59
smf_event_length_is_valid
int smf_event_length_is_valid(const smf_event_t *event) WARN_UNUSED_RESULT
Definition: smf_load.c:718
chunk_header_struct
SMF chunk header, used only by smf_load.c and smf_save.c.
Definition: smf_private.h:53
smf_struct
Represents a "song", that is, collection of one or more tracks.
Definition: smf.h:230
chunk_header_struct::length
uint32_t length
Definition: smf_private.h:55
smf_track_struct
Represents a single track.
Definition: smf.h:271
smf_init_tempo
void smf_init_tempo(smf_t *smf)
Definition: smf_tempo.c:367
smf_create_tempo_map_and_compute_seconds
void smf_create_tempo_map_and_compute_seconds(smf_t *smf)
Definition: smf_tempo.c:235
maybe_add_to_tempo_map
void maybe_add_to_tempo_map(smf_event_t *event)
Definition: smf_tempo.c:125
is_status_byte
int is_status_byte(const unsigned char status) WARN_UNUSED_RESULT
Returns 1 if the given byte is a valid status byte, 0 otherwise.
Definition: smf_load.c:251
remove_last_tempo_with_pulses
void remove_last_tempo_with_pulses(smf_t *smf, int pulses)
Definition: smf_tempo.c:173
mthd_chunk_struct::number_of_tracks
uint16_t number_of_tracks
Definition: smf_private.h:62
smf_track_add_event
void smf_track_add_event(smf_track_t *track, smf_event_t *event)
Adds the event to the track and computes ->delta_pulses.
Definition: smf.c:441
mthd_chunk_struct::format
uint16_t format
Definition: smf_private.h:61
smf_event_struct
Represents a single MIDI event or metaevent.
Definition: smf.h:301
smf_event_is_tempo_change_or_time_signature
int smf_event_is_tempo_change_or_time_signature(const smf_event_t *event) WARN_UNUSED_RESULT
Definition: smf.c:631
mthd_chunk_struct::mthd_header
struct chunk_header_struct mthd_header
Definition: smf_private.h:60
smf_fini_tempo
void smf_fini_tempo(smf_t *smf)
Definition: smf_tempo.c:342
mthd_chunk_struct::division
uint16_t division
Definition: smf_private.h:63
ATTRIBUTE_PACKED
struct chunk_header_struct ATTRIBUTE_PACKED
smf
smf_t * smf
Definition: smfsh.c:56