00001 /*- 00002 * Copyright (c) 2007, 2008 Edward Tomasz NapieraĆa <trasz@FreeBSD.org> 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * ALTHOUGH THIS SOFTWARE IS MADE OF WIN AND SCIENCE, IT IS PROVIDED BY THE 00015 * AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00018 * THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00019 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00020 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00021 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00022 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00023 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 * 00026 */ 00027 00028 #ifndef SMF_PRIVATE_H 00029 #define SMF_PRIVATE_H 00030 00031 #include <stdint.h> 00032 #include <sys/types.h> 00033 00034 #include "config.h" 00035 00036 #define SMF_VERSION PACKAGE_VERSION 00037 00045 #if defined(__GNUC__) 00046 #define ATTRIBUTE_PACKED __attribute__((__packed__)) 00047 #else 00048 #define ATTRIBUTE_PACKED 00049 #pragma pack(1) 00050 #endif 00051 00053 struct chunk_header_struct { 00054 char id[4]; 00055 uint32_t length; 00056 } ATTRIBUTE_PACKED; 00057 00059 struct mthd_chunk_struct { 00060 struct chunk_header_struct mthd_header; 00061 uint16_t format; 00062 uint16_t number_of_tracks; 00063 uint16_t division; 00064 } ATTRIBUTE_PACKED; 00065 00066 #if (!defined __GNUC__) 00067 #pragma pack() 00068 #endif 00069 00070 void smf_track_add_event(smf_track_t *track, smf_event_t *event); 00071 void smf_init_tempo(smf_t *smf); 00072 void smf_fini_tempo(smf_t *smf); 00073 void smf_create_tempo_map_and_compute_seconds(smf_t *smf); 00074 void maybe_add_to_tempo_map(smf_event_t *event); 00075 void remove_last_tempo_with_pulses(smf_t *smf, int pulses); 00076 int smf_event_is_tempo_change_or_time_signature(const smf_event_t *event) WARN_UNUSED_RESULT; 00077 int smf_event_length_is_valid(const smf_event_t *event) WARN_UNUSED_RESULT; 00078 int is_status_byte(const unsigned char status) WARN_UNUSED_RESULT; 00079 00080 #endif /* SMF_PRIVATE_H */ 00081