Commit graph

19 commits

Author SHA1 Message Date
Paul Davis
65332e603b libsmf: speed up ridiculous design of smf_save()
This would realloc a buffer for every event, making it absurdly slow for
large MIDI files (say, 10k events). Use the somewhat standard heuristic
of doubling the requested allocation every time we need to increase the size.

This results in a speedup of 40-100x when saving SMF to disk
2025-11-17 16:05:03 -07:00
Paul Davis
efcb26d7c1 add smf_length_is_explicit() to libsmf 2025-02-28 16:49:15 -07:00
Mads Kiilerich
b4ff4f356c Make header files more self-contained - add missing Ardour and lib includes 2024-10-20 03:30:46 +02:00
Robin Gareus
1cd78c94d3
Improve doxygen's main page, add references 2024-05-28 01:00:42 +02:00
Robin Gareus
b269a1298c
Fix memory leak for invalid SMF event 2022-10-04 03:29:52 +02:00
Paul Davis
0d9656ef82 use new macros to cleanup #ifndef NDEBUG as much as possible (libs edition) 2022-06-22 13:31:08 -06:00
Paul Davis
9b80d6558a fix optimized unused variable warning 2022-06-22 13:31:08 -06:00
Paul Davis
ad8e1c1cfd fix optimized unused variable warnings 2022-06-22 13:31:08 -06:00
Robin Gareus
cd53301d06
Significantly speed up loading SMF tempo-maps
Files that have many tracks, each with tempo information
were near impossible to load (30+ mins on modern 4.2Ghz CPU!),
because tempo is parsed incrementally:

```
For each new track:
  for each new tempo-event:
    rewind()
    for each loaded track so far:
      for each event on this track so far
```

This reduces the complexity from O(tracks^2 * tempos^2)
to O(tracks * tempos).

"Come Thou Fount Tempo Map.mid" has 238 Tracks and 56168 total
Tempo Changes (236 per track). This now requires only 56168 iterations
in smf_create_tempo_map_and_compute_seconds, rather than 1.64e+9
iterations
2022-02-05 17:33:21 +01:00
Paul Davis
336319a1df SMF meta-events do not set running status while parsing the file 2021-06-22 14:18:03 -06:00
Robin Gareus
c6b87972b1
Remove unused libsmf seconds/time API
This significantly speeds up parsing MIDI files with complex
tempo-maps. e.g. "Black MIDI Trilogy_2.mid" has 24134 Tempo
changes. Prior to this commit parsing that file took over 5 minutes.
now it loads in under one seconds (libsmf only; libardour still
add overhead, and now needs about 30-40 seconds, previously
it took about 10 mins).

The problem was that every call to `smf_track_add_event_pulses()`
calls `seconds_from_pulses()` which calls `smf_get_tempo_by_seconds()`
which iterates over the tempo-map:

  for every midi-event { for ever tempo until that midi-event {..} }

This does not scale to 3.5M events and 24k tempo-changes.
2020-07-16 18:38:03 +02:00
Robin Gareus
ba7db8759b
SMF: remove unused variable (from 803dab7d87) 2020-07-16 18:35:43 +02:00
Robin Gareus
803dab7d87
SMF: various backports from libsmf PR7
see also https://github.com/stump/libsmf/pull/7

* Fix validity checks of escaped data
* Handle non-EOT-terminated tracks.
* Fix buffer overflow on tempo change event
* Fix memory leaks in case loading fails
* Fix a logic errors in extract_escaped_event()
* Fix the assertion problem `is_sysex_byte(status)`
* Make libsmf more tolerant to malformed MIDI files.
  (fixes import of files generated by NoteEdit)
2020-07-16 18:00:40 +02:00
Robin Gareus
23e6dd5f6b
NO-OP: backport some libsmf doc and warnings 2020-07-16 17:58:04 +02:00
Robin Gareus
43158047ed
SMF: use glib macros for endian conversion 2020-07-16 17:57:59 +02:00
Robin Gareus
c264ab6c95
Remove debug output 2020-04-23 02:29:45 +02:00
Paul Davis
9a93583ef7 fully initialize SMF tempo information to default (4/4, 120bpm)
Leaving CPC and 32nd-per-quarter at -1 causes arithmetic errors later if the SMF
file doesn't contain an explicit time signature meta-event
2020-04-21 21:17:14 -06:00
David Robillard
39bdde4250 Use labs() for long instead of abs() 2019-12-09 23:25:51 +01:00
Paul Davis
eaae38ba84 move evoral/src/* to evoral/ 2019-11-02 16:32:18 -06:00