mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2025-02-28 15:30:32 +01:00
This segfault in a nasty way ...
This commit is contained in:
parent
8150977ae7
commit
6242202519
@ -1,5 +1,6 @@
|
|||||||
#include "open_music.hpp"
|
#include "open_music.hpp"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -166,7 +167,7 @@ bool OpenMusic::onGetData(SoundStream::Chunk& data) {
|
|||||||
current_offset += data.sampleCount;
|
current_offset += data.sampleCount;
|
||||||
|
|
||||||
// Check if we have stopped obtaining samples or reached either the EOF or the loop end point
|
// Check if we have stopped obtaining samples or reached either the EOF or the loop end point
|
||||||
return (data.sampleCount != 0) && (current_offset < m_file.getSampleCount()) && !(current_offset == loopEnd && m_loopSpan.length != 0);
|
return (data.sampleCount != 0) && (static_cast<std::size_t>(current_offset) < m_file.getSampleCount()) && !(current_offset == loopEnd && m_loopSpan.length != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,8 +20,10 @@ struct PreciseSoundStream : public OpenSoundStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
sf::Uint64 time_to_samples(sf::Time position, T sample_rate, T channel_count) {
|
std::int64_t time_to_samples(sf::Time position, T sample_rate, T channel_count) {
|
||||||
return ((static_cast<sf::Uint64>(position.asMicroseconds()) * sample_rate * channel_count) + 500000) / 1000000;
|
const auto signed_sample_rate = static_cast<std::int64_t>(sample_rate);
|
||||||
|
const auto signed_channel_count = static_cast<std::int64_t>(channel_count);
|
||||||
|
return ((static_cast<std::int64_t>(position.asMicroseconds()) * signed_sample_rate * signed_channel_count) + 500000) / 1000000;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -21,18 +21,6 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "precise_sound_stream.hpp"
|
#include "precise_sound_stream.hpp"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable: 4355) // 'this' used in base member initializer list
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#if defined(__clang__)
|
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void InternalStream::clear_queue() {
|
void InternalStream::clear_queue() {
|
||||||
// Get the number of buffers still in the queue
|
// Get the number of buffers still in the queue
|
||||||
|
@ -34,7 +34,7 @@ struct Buffers {
|
|||||||
// Format of the internal sound buffers
|
// Format of the internal sound buffers
|
||||||
sf::Int32 m_format = 0;
|
sf::Int32 m_format = 0;
|
||||||
// Number of samples processed since beginning of the stream
|
// Number of samples processed since beginning of the stream
|
||||||
sf::Uint64 m_samplesProcessed = 0;
|
std::int64_t m_samplesProcessed = 0;
|
||||||
// If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation.
|
// If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation.
|
||||||
std::array<sf::Int64, BufferCount> m_bufferSeeks = {0, 0, 0};
|
std::array<sf::Int64, BufferCount> m_bufferSeeks = {0, 0, 0};
|
||||||
};
|
};
|
||||||
|
@ -370,11 +370,7 @@ void EditorState::set_playback_position(std::variant<sf::Time, Fraction> newPosi
|
|||||||
previous_playback_position = playback_position;
|
previous_playback_position = playback_position;
|
||||||
playback_position = newPosition;
|
playback_position = newPosition;
|
||||||
const auto now = current_time();
|
const auto now = current_time();
|
||||||
if (now >= sf::Time::Zero and now < editable_range.end) {
|
audio.setPlayingOffset(now);
|
||||||
audio.setPlayingOffset(now);
|
|
||||||
} else {
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sf::Time EditorState::get_precise_playback_position() {
|
sf::Time EditorState::get_precise_playback_position() {
|
||||||
@ -1170,6 +1166,7 @@ void EditorState::display_timing_menu() {
|
|||||||
if (chart_state) {
|
if (chart_state) {
|
||||||
chart_state->density_graph.should_recompute = true;
|
chart_state->density_graph.should_recompute = true;
|
||||||
}
|
}
|
||||||
|
reload_editable_range();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -1394,8 +1391,10 @@ void EditorState::reload_editable_range() {
|
|||||||
Interval<sf::Time> EditorState::choose_editable_range() {
|
Interval<sf::Time> EditorState::choose_editable_range() {
|
||||||
Interval<sf::Time> new_range{sf::Time::Zero, sf::Time::Zero};
|
Interval<sf::Time> new_range{sf::Time::Zero, sf::Time::Zero};
|
||||||
if (music.has_value()) {
|
if (music.has_value()) {
|
||||||
// If there is music, allow editing up to the end, but no further
|
// If there is music, allow editing from beat zero (which might be at
|
||||||
|
// a negative time in seconds) and up to the end, but no further
|
||||||
// You've put notes *after* the end of the music ? fuck 'em.
|
// You've put notes *after* the end of the music ? fuck 'em.
|
||||||
|
new_range += applicable_timing->time_at(0);
|
||||||
new_range += (**music).getDuration();
|
new_range += (**music).getDuration();
|
||||||
return new_range;
|
return new_range;
|
||||||
} else {
|
} else {
|
||||||
|
@ -307,8 +307,8 @@ void LinearView::draw_in_waveform_mode(LinearView::DrawArgs& args) {
|
|||||||
const auto frac_chunk_at_cursor = static_cast<std::int64_t>(std::floor(
|
const auto frac_chunk_at_cursor = static_cast<std::int64_t>(std::floor(
|
||||||
static_cast<double>(sample_at_cursor) / waveform.channel_count / chunk_sizes.fractional
|
static_cast<double>(sample_at_cursor) / waveform.channel_count / chunk_sizes.fractional
|
||||||
));
|
));
|
||||||
const auto first_chunk = frac_chunk_at_cursor - static_cast<std::int64_t>(sizes.cursor_height);
|
const std::int64_t first_chunk = frac_chunk_at_cursor - static_cast<std::int64_t>(sizes.cursor_height);
|
||||||
const auto end_chunk = first_chunk + static_cast<std::int64_t>(work_rect.GetHeight());
|
const std::int64_t end_chunk = first_chunk + static_cast<std::int64_t>(work_rect.GetHeight());
|
||||||
const AffineTransform<float> seconds_to_pixels_proportional {
|
const AffineTransform<float> seconds_to_pixels_proportional {
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user