summaryrefslogtreecommitdiff
path: root/libs/evoral/src
diff options
context:
space:
mode:
Diffstat (limited to 'libs/evoral/src')
-rw-r--r--libs/evoral/src/ControlList.cpp2
-rw-r--r--libs/evoral/src/Curve.cpp5
-rw-r--r--libs/evoral/src/IdentityConverter.cpp43
-rw-r--r--libs/evoral/src/Note.impl112
-rw-r--r--libs/evoral/src/SMF.cpp4
-rw-r--r--libs/evoral/src/Sequence.cpp40
-rw-r--r--libs/evoral/src/libsmf/smf.c32
-rw-r--r--libs/evoral/src/libsmf/smf_decode.c20
-rw-r--r--libs/evoral/src/libsmf/smf_load.c28
-rw-r--r--libs/evoral/src/libsmf/smf_private.h1
-rw-r--r--libs/evoral/src/libsmf/smf_save.c14
-rw-r--r--libs/evoral/src/libsmf/smf_tempo.c14
12 files changed, 271 insertions, 44 deletions
diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp
index a095daa135..2453574e5c 100644
--- a/libs/evoral/src/ControlList.cpp
+++ b/libs/evoral/src/ControlList.cpp
@@ -812,7 +812,7 @@ ControlList::modify (iterator iter, double when, double val)
(*iter)->when = when;
(*iter)->value = val;
- if (std::isnan (val)) {
+ if (isnan (val)) {
abort ();
}
diff --git a/libs/evoral/src/Curve.cpp b/libs/evoral/src/Curve.cpp
index 6f3532fdcb..44fc48f728 100644
--- a/libs/evoral/src/Curve.cpp
+++ b/libs/evoral/src/Curve.cpp
@@ -22,6 +22,7 @@
#include <climits>
#include <cfloat>
#include <cmath>
+#include <vector>
#include <glibmm/threads.h>
@@ -56,8 +57,8 @@ Curve::solve ()
(www.korf.co.uk/spline.pdf) for more details.
*/
- double x[npoints];
- double y[npoints];
+ vector<double> x(npoints);
+ vector<double> y(npoints);
uint32_t i;
ControlList::EventList::const_iterator xx;
diff --git a/libs/evoral/src/IdentityConverter.cpp b/libs/evoral/src/IdentityConverter.cpp
new file mode 100644
index 0000000000..1af21debae
--- /dev/null
+++ b/libs/evoral/src/IdentityConverter.cpp
@@ -0,0 +1,43 @@
+/* This file is part of Evoral.
+ * Copyright (C) 2008 David Robillard <http://drobilla.net>
+ * Copyright (C) 2000-2008 Paul Davis
+ *
+ * Evoral is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+#include "evoral/TimeConverter.hpp"
+
+typedef int64_t framepos_t; /* MUST match libs/ardour/ardour/types.h */
+
+namespace Evoral {
+
+template<typename A, typename B>
+B
+IdentityConverter<A,B>::to(A a) const
+{
+ return static_cast<B>(a);
+}
+
+template<typename A, typename B>
+A
+IdentityConverter<A,B>::from(B b) const
+{
+ return static_cast<A>(b);
+}
+
+template class IdentityConverter<double, framepos_t>;
+template class TimeConverter<double, framepos_t>;
+
+} // namespace Evoral
diff --git a/libs/evoral/src/Note.impl b/libs/evoral/src/Note.impl
new file mode 100644
index 0000000000..d63e31a831
--- /dev/null
+++ b/libs/evoral/src/Note.impl
@@ -0,0 +1,112 @@
+/* This file is part of Evoral.
+ * Copyright (C) 2008 David Robillard <http://drobilla.net>
+ * Copyright (C) 2000-2008 Paul Davis
+ *
+ * Evoral is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <iostream>
+#include <limits>
+#include <glib.h>
+// Commented out by JE - 23-10-2013 #include "evoral/Note.hpp"
+
+namespace Evoral {
+
+template<typename Time>
+Note<Time>::Note(uint8_t chan, Time t, Time l, uint8_t n, uint8_t v)
+ // FIXME: types?
+ : _on_event (0xDE, t, 3, NULL, true)
+ , _off_event (0xAD, t + l, 3, NULL, true)
+{
+ assert(chan < 16);
+
+ _on_event.buffer()[0] = MIDI_CMD_NOTE_ON + chan;
+ _on_event.buffer()[1] = n;
+ _on_event.buffer()[2] = v;
+
+ _off_event.buffer()[0] = MIDI_CMD_NOTE_OFF + chan;
+ _off_event.buffer()[1] = n;
+ _off_event.buffer()[2] = 0x40;
+
+ assert(musical_time_equal (time(),t));
+ assert(musical_time_equal (length(), l));
+ assert(note() == n);
+ assert(velocity() == v);
+ assert(_on_event.channel() == _off_event.channel());
+ assert(channel() == chan);
+}
+
+
+template<typename Time>
+Note<Time>::Note(const Note<Time>& copy)
+ : _on_event(copy._on_event, true)
+ , _off_event(copy._off_event, true)
+{
+ set_id (copy.id());
+
+ assert(_on_event.buffer());
+ assert(_off_event.buffer());
+ /*
+ assert(copy._on_event.size == 3);
+ _on_event.buffer = _on_event_buffer;
+ memcpy(_on_event_buffer, copy._on_event_buffer, 3);
+
+ assert(copy._off_event.size == 3);
+ _off_event.buffer = _off_event_buffer;
+ memcpy(_off_event_buffer, copy._off_event_buffer, 3);
+ */
+
+ assert(musical_time_equal (time(),copy.time()));
+ assert(musical_time_equal (end_time(), copy.end_time()));
+ assert(musical_time_equal (length(), copy.length()));
+ assert(note() == copy.note());
+ assert(velocity() == copy.velocity());
+ assert(_on_event.channel() == _off_event.channel());
+ assert(channel() == copy.channel());
+}
+
+template<typename Time>
+Note<Time>::~Note()
+{
+}
+
+template<typename Time> void
+Note<Time>::set_id (event_id_t id)
+{
+ _on_event.set_id (id);
+ _off_event.set_id (id);
+}
+
+template<typename Time>
+const Note<Time>&
+Note<Time>::operator=(const Note<Time>& other)
+{
+ _on_event = other._on_event;
+ _off_event = other._off_event;
+
+ assert(musical_time_equal (time(),other.time()));
+ assert(musical_time_equal (end_time(), other.end_time()));
+ assert(musical_time_equal (length(), other.length()));
+ assert(note() == other.note());
+ assert(velocity() == other.velocity());
+ assert(_on_event.channel() == _off_event.channel());
+ assert(channel() == other.channel());
+
+ return *this;
+}
+
+template class Note<Evoral::MusicalTime>;
+
+} // namespace Evoral
+
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index b84507818c..8b2d10d197 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -27,6 +27,10 @@
#include "evoral/midi_util.h"
#include "pbd/file_manager.h"
+#ifdef COMPILER_MSVC
+extern double round(double x);
+#endif
+
using namespace std;
namespace Evoral {
diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp
index 204ef58f33..7084a90491 100644
--- a/libs/evoral/src/Sequence.cpp
+++ b/libs/evoral/src/Sequence.cpp
@@ -1201,11 +1201,13 @@ Sequence<Time>::overlaps_unlocked (const NotePtr& note, const NotePtr& without)
template<typename Time>
void
-Sequence<Time>::set_notes (const Sequence<Time>::Notes& n)
+Sequence<Time>::set_notes (const typename Sequence<Time>::Notes& n)
{
_notes = n;
}
+// CONST iterator implementations (x3)
+
/** Return the earliest note with time >= t */
template<typename Time>
typename Sequence<Time>::Notes::const_iterator
@@ -1239,6 +1241,41 @@ Sequence<Time>::sysex_lower_bound (Time t) const
return i;
}
+// NON-CONST iterator implementations (x3)
+
+/** Return the earliest note with time >= t */
+template<typename Time>
+typename Sequence<Time>::Notes::iterator
+Sequence<Time>::note_lower_bound (Time t)
+{
+ NotePtr search_note(new Note<Time>(0, t, 0, 0, 0));
+ typename Sequence<Time>::Notes::iterator i = _notes.lower_bound(search_note);
+ assert(i == _notes.end() || (*i)->time() >= t);
+ return i;
+}
+
+/** Return the earliest patch change with time >= t */
+template<typename Time>
+typename Sequence<Time>::PatchChanges::iterator
+Sequence<Time>::patch_change_lower_bound (Time t)
+{
+ PatchChangePtr search (new PatchChange<Time> (t, 0, 0, 0));
+ typename Sequence<Time>::PatchChanges::iterator i = _patch_changes.lower_bound (search);
+ assert (i == _patch_changes.end() || musical_time_greater_or_equal_to ((*i)->time(), t));
+ return i;
+}
+
+/** Return the earliest sysex with time >= t */
+template<typename Time>
+typename Sequence<Time>::SysExes::iterator
+Sequence<Time>::sysex_lower_bound (Time t)
+{
+ SysExPtr search (new Event<Time> (0, t));
+ typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search);
+ assert (i == _sysexes.end() || (*i)->time() >= t);
+ return i;
+}
+
template<typename Time>
void
Sequence<Time>::get_notes (Notes& n, NoteOperator op, uint8_t val, int chan_mask) const
@@ -1393,4 +1430,3 @@ Sequence<Time>::dump (ostream& str) const
template class Sequence<Evoral::MusicalTime>;
} // namespace Evoral
-
diff --git a/libs/evoral/src/libsmf/smf.c b/libs/evoral/src/libsmf/smf.c
index b79d7543b6..3fde1d831e 100644
--- a/libs/evoral/src/libsmf/smf.c
+++ b/libs/evoral/src/libsmf/smf.c
@@ -39,7 +39,11 @@
#include <assert.h>
#include <math.h>
#include <errno.h>
+#ifdef PLATFORM_WINDOWS
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include "smf.h"
#include "smf_private.h"
@@ -52,7 +56,7 @@ smf_new(void)
{
int cantfail;
- smf_t *smf = malloc(sizeof(smf_t));
+ smf_t *smf = (smf_t*)malloc(sizeof(smf_t));
if (smf == NULL) {
g_critical("Cannot allocate smf_t structure: %s", strerror(errno));
return (NULL);
@@ -85,7 +89,7 @@ smf_delete(smf_t *smf)
{
/* Remove all the tracks, from last to first. */
while (smf->tracks_array->len > 0)
- smf_track_delete(g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1));
+ smf_track_delete((smf_track_t*)g_ptr_array_index(smf->tracks_array, smf->tracks_array->len - 1));
smf_fini_tempo(smf);
@@ -105,7 +109,7 @@ smf_delete(smf_t *smf)
smf_track_t *
smf_track_new(void)
{
- smf_track_t *track = malloc(sizeof(smf_track_t));
+ smf_track_t *track = (smf_track_t*)malloc(sizeof(smf_track_t));
if (track == NULL) {
g_critical("Cannot allocate smf_track_t structure: %s", strerror(errno));
return (NULL);
@@ -131,7 +135,7 @@ smf_track_delete(smf_track_t *track)
/* Remove all the events, from last to first. */
while (track->events_array->len > 0)
- smf_event_delete(g_ptr_array_index(track->events_array, track->events_array->len - 1));
+ smf_event_delete((smf_event_t*)g_ptr_array_index(track->events_array, track->events_array->len - 1));
if (track->smf)
smf_track_remove_from_smf(track);
@@ -151,7 +155,9 @@ smf_track_delete(smf_track_t *track)
void
smf_add_track(smf_t *smf, smf_track_t *track)
{
+#ifndef NDEBUG
int cantfail;
+#endif
assert(track->smf == NULL);
@@ -162,8 +168,13 @@ smf_add_track(smf_t *smf, smf_track_t *track)
track->track_number = smf->number_of_tracks;
if (smf->number_of_tracks > 1) {
+#ifndef NDEBUG
cantfail = smf_set_format(smf, 1);
assert(!cantfail);
+#else
+ smf_set_format(smf, 1);
+#endif
+
}
}
@@ -213,7 +224,7 @@ smf_track_remove_from_smf(smf_track_t *track)
smf_event_t *
smf_event_new(void)
{
- smf_event_t *event = malloc(sizeof(smf_event_t));
+ smf_event_t *event = (smf_event_t*)malloc(sizeof(smf_event_t));
if (event == NULL) {
g_critical("Cannot allocate smf_event_t structure: %s", strerror(errno));
return (NULL);
@@ -246,7 +257,7 @@ smf_event_new_from_pointer(const void *midi_data, size_t len)
return (NULL);
event->midi_buffer_length = len;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
smf_event_delete(event);
@@ -336,7 +347,7 @@ smf_event_new_from_bytes(int first_byte, int second_byte, int third_byte)
}
event->midi_buffer_length = len;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
smf_event_delete(event);
@@ -773,7 +784,7 @@ smf_track_get_event_by_number(const smf_track_t *track, size_t event_number)
if (event_number > track->number_of_events)
return (NULL);
- event = g_ptr_array_index(track->events_array, event_number - 1);
+ event = (smf_event_t*)g_ptr_array_index(track->events_array, event_number - 1);
assert(event);
@@ -860,9 +871,8 @@ smf_get_next_event(smf_t *smf)
void
smf_skip_next_event(smf_t *smf)
{
- void *notused;
-
- notused = smf_get_next_event(smf);
+ smf_event_t *ignored = smf_get_next_event(smf);
+ (void) ignored;
}
/**
diff --git a/libs/evoral/src/libsmf/smf_decode.c b/libs/evoral/src/libsmf/smf_decode.c
index bfba08e9f9..8037fd80d2 100644
--- a/libs/evoral/src/libsmf/smf_decode.c
+++ b/libs/evoral/src/libsmf/smf_decode.c
@@ -37,7 +37,11 @@
#include <assert.h>
#include <math.h>
#include <errno.h>
+#ifdef PLATFORM_WINDOWS
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include <stdint.h>
#include "smf.h"
#include "smf_private.h"
@@ -114,7 +118,7 @@ smf_event_decode_textual(const smf_event_t *event, const char *name)
int off = 0;
char *buf, *extracted;
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode_textual: malloc failed.");
return (NULL);
@@ -177,7 +181,7 @@ smf_event_decode_metadata(const smf_event_t *event)
break;
}
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode_metadata: malloc failed.");
return (NULL);
@@ -235,7 +239,7 @@ smf_event_decode_metadata(const smf_event_t *event)
off += snprintf(buf + off, BUFFER_SIZE - off,
"Time Signature: %d/%d, %d clocks per click, %d notated 32nd notes per quarter note",
- event->midi_buffer[3], (int)pow(2, event->midi_buffer[4]), event->midi_buffer[5],
+ event->midi_buffer[3], (int)pow((double)2, event->midi_buffer[4]), event->midi_buffer[5],
event->midi_buffer[6]);
break;
@@ -302,7 +306,7 @@ smf_event_decode_system_realtime(const smf_event_t *event)
return (NULL);
}
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode_system_realtime: malloc failed.");
return (NULL);
@@ -354,7 +358,7 @@ smf_event_decode_sysex(const smf_event_t *event)
return (NULL);
}
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode_sysex: malloc failed.");
return (NULL);
@@ -455,7 +459,7 @@ smf_event_decode_system_common(const smf_event_t *event)
if (smf_event_is_sysex(event))
return (smf_event_decode_sysex(event));
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode_system_realtime: malloc failed.");
return (NULL);
@@ -526,7 +530,7 @@ smf_event_decode(const smf_event_t *event)
return (NULL);
}
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode: malloc failed.");
return (NULL);
@@ -596,7 +600,7 @@ smf_decode(const smf_t *smf)
int off = 0;
char *buf;
- buf = malloc(BUFFER_SIZE);
+ buf = (char*)malloc(BUFFER_SIZE);
if (buf == NULL) {
g_critical("smf_event_decode: malloc failed.");
return (NULL);
diff --git a/libs/evoral/src/libsmf/smf_load.c b/libs/evoral/src/libsmf/smf_load.c
index f27d092a8b..d8168d0e6a 100644
--- a/libs/evoral/src/libsmf/smf_load.c
+++ b/libs/evoral/src/libsmf/smf_load.c
@@ -40,7 +40,11 @@
#include <math.h>
#include <errno.h>
#include <ctype.h>
+#ifdef PLATFORM_WINDOWS
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include "smf.h"
#include "smf_private.h"
@@ -119,7 +123,7 @@ parse_mthd_header(smf_t *smf)
return (-1);
}
- tmp_mthd = smf->file_buffer;
+ tmp_mthd = (struct chunk_header_struct*)smf->file_buffer;
if (!chunk_signature_matches(tmp_mthd, "MThd")) {
g_critical("SMF error: MThd signature not found, is that a MIDI file?");
@@ -278,7 +282,11 @@ expected_sysex_length(const unsigned char status, const unsigned char *second_by
uint32_t sysex_length = 0;
uint32_t len = 0;
+#ifndef NDEBUG
+ (void) status;
+#else
assert(status == 0xF0);
+#endif
if (buffer_length < 3) {
g_critical("SMF error: end of buffer in expected_sysex_length().");
@@ -405,7 +413,7 @@ extract_sysex_event(const unsigned char *buf, const size_t buffer_length, smf_ev
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno));
return (-4);
@@ -448,7 +456,7 @@ extract_escaped_event(const unsigned char *buf, const size_t buffer_length, smf_
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno));
return (-4);
@@ -518,7 +526,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno));
return (-4);
@@ -541,7 +549,7 @@ extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve
static smf_event_t *
parse_next_event(smf_track_t *track)
{
- uint32_t time = 0;
+ uint32_t etime = 0;
uint32_t len;
size_t buffer_length;
unsigned char *c, *start;
@@ -560,7 +568,7 @@ parse_next_event(smf_track_t *track)
assert(buffer_length > 0);
/* First, extract time offset from previous event. */
- if (smf_extract_vlq(c, buffer_length, &time, &len))
+ if (smf_extract_vlq(c, buffer_length, &etime, &len))
goto error;
c += len;
@@ -578,7 +586,7 @@ parse_next_event(smf_track_t *track)
track->last_status = event->midi_buffer[0];
track->next_event_offset += c - start;
- smf_track_add_event_delta_pulses(track, event, time);
+ smf_track_add_event_delta_pulses(track, event, etime);
return (event);
@@ -607,7 +615,7 @@ make_string(const unsigned char *buf, const size_t buffer_length, uint32_t len)
len = buffer_length;
}
- str = malloc(len + 1);
+ str = (char*)malloc(len + 1);
if (str == NULL) {
g_critical("Cannot allocate memory in make_string().");
return (NULL);
@@ -658,14 +666,14 @@ smf_event_extract_text(const smf_event_t *event)
return (NULL);
}
- smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
+ smf_extract_vlq((const unsigned char*)(void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
if (string_length <= 0) {
g_critical("smf_event_extract_text: truncated MIDI message.");
return (NULL);
}
- return (make_string((void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
+ return (make_string((const unsigned char*)(void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
}
/**
diff --git a/libs/evoral/src/libsmf/smf_private.h b/libs/evoral/src/libsmf/smf_private.h
index 537a29b889..f415eac9da 100644
--- a/libs/evoral/src/libsmf/smf_private.h
+++ b/libs/evoral/src/libsmf/smf_private.h
@@ -75,6 +75,7 @@ void remove_last_tempo_with_pulses(smf_t *smf, size_t pulses);
int smf_event_is_tempo_change_or_time_signature(const smf_event_t *event) WARN_UNUSED_RESULT;
int smf_event_length_is_valid(const smf_event_t *event) WARN_UNUSED_RESULT;
int is_status_byte(const unsigned char status) WARN_UNUSED_RESULT;
+smf_track_t* smf_find_track_with_next_event (smf_t *smf);
#endif /* SMF_PRIVATE_H */
diff --git a/libs/evoral/src/libsmf/smf_save.c b/libs/evoral/src/libsmf/smf_save.c
index b99af75461..120c3a95eb 100644
--- a/libs/evoral/src/libsmf/smf_save.c
+++ b/libs/evoral/src/libsmf/smf_save.c
@@ -39,7 +39,11 @@
#include <assert.h>
#include <math.h>
#include <errno.h>
+#ifdef PLATFORM_WINDOWS
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include "smf.h"
#include "smf_private.h"
@@ -54,7 +58,7 @@ static void *
smf_extend(smf_t *smf, const int length)
{
int i, previous_file_buffer_length = smf->file_buffer_length;
- char *previous_file_buffer = smf->file_buffer;
+ char *previous_file_buffer = (char*)smf->file_buffer;
/* XXX: Not terribly efficient. */
smf->file_buffer_length += length;
@@ -201,7 +205,7 @@ smf_event_new_textual(int type, const char *text)
/* "2 +" is for leading 0xFF 0xtype. */
event->midi_buffer_length = 2 + text_length + MAX_VLQ_LENGTH;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer = (uint8_t*)malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate MIDI buffer structure: %s", strerror(errno));
smf_event_delete(event);
@@ -215,7 +219,11 @@ smf_event_new_textual(int type, const char *text)
vlq_length = smf_format_vlq(event->midi_buffer + 2, MAX_VLQ_LENGTH - 2, text_length);
copied_length = snprintf((char *)event->midi_buffer + vlq_length + 2, event->midi_buffer_length - vlq_length - 2, "%s", text);
+#ifndef NDEBUG
+ (void) copied_length; /* stop gcc warning about unusued vars for non-debug build */
+#else
assert(copied_length == text_length);
+#endif
event->midi_buffer_length = 2 + vlq_length + text_length;
@@ -541,7 +549,7 @@ assert_smf_event_is_identical(const smf_event_t *a, const smf_event_t *b)
{
assert(a->event_number == b->event_number);
assert(a->delta_time_pulses == b->delta_time_pulses);
- assert(abs(a->time_pulses - b->time_pulses) <= 2);
+ assert(abs((long)(a->time_pulses - b->time_pulses)) <= 2);
assert(fabs(a->time_seconds - b->time_seconds) <= 0.01);
assert(a->track_number == b->track_number);
assert(a->midi_buffer_length == b->midi_buffer_length);
diff --git a/libs/evoral/src/libsmf/smf_tempo.c b/libs/evoral/src/libsmf/smf_tempo.c
index c24e7460c1..f3e3f7fc1b 100644
--- a/libs/evoral/src/libsmf/smf_tempo.c
+++ b/libs/evoral/src/libsmf/smf_tempo.c
@@ -59,7 +59,7 @@ new_tempo(smf_t *smf, size_t pulses)
return (previous_tempo);
}
- tempo = malloc(sizeof(smf_tempo_t));
+ tempo = (smf_tempo_t*)malloc(sizeof(smf_tempo_t));
if (tempo == NULL) {
g_critical("Cannot allocate smf_tempo_t.");
return (NULL);
@@ -133,13 +133,13 @@ maybe_add_to_tempo_map(smf_event_t *event)
/* Tempo Change? */
if (event->midi_buffer[1] == 0x51) {
- int new_tempo = (event->midi_buffer[3] << 16) + (event->midi_buffer[4] << 8) + event->midi_buffer[5];
- if (new_tempo <= 0) {
+ int ntempo = (event->midi_buffer[3] << 16) + (event->midi_buffer[4] << 8) + event->midi_buffer[5];
+ if (ntempo <= 0) {
g_critical("Ignoring invalid tempo change.");
return;
}
- add_tempo(event->track->smf, event->time_pulses, new_tempo);
+ add_tempo(event->track->smf, event->time_pulses, ntempo);
}
/* Time Signature? */
@@ -152,7 +152,7 @@ maybe_add_to_tempo_map(smf_event_t *event)
}
numerator = event->midi_buffer[3];
- denominator = (int)pow(2, event->midi_buffer[4]);
+ denominator = (int)pow((double)2, event->midi_buffer[4]);
clocks_per_click = event->midi_buffer[5];
notes_per_note = event->midi_buffer[6];
@@ -259,7 +259,7 @@ smf_get_tempo_by_number(const smf_t *smf, size_t number)
if (number >= smf->tempo_array->len)
return (NULL);
- return (g_ptr_array_index(smf->tempo_array, number));
+ return ((smf_tempo_t*)g_ptr_array_index(smf->tempo_array, number));
}
/**
@@ -341,7 +341,7 @@ smf_fini_tempo(smf_t *smf)
smf_tempo_t *tempo;
while (smf->tempo_array->len > 0) {
- tempo = g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1);
+ tempo = (smf_tempo_t*)g_ptr_array_index(smf->tempo_array, smf->tempo_array->len - 1);
assert(tempo);
memset(tempo, 0, sizeof(smf_tempo_t));