Phase 6: Add WAV clips, graph playback and bounded recording
This commit is contained in:
parent
65640c4aad
commit
8a37090b81
40 changed files with 1450 additions and 69 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "project_internal.h"
|
||||
#include "xtc/xtc_audio.h"
|
||||
#include "../graph/graph_internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -214,9 +215,29 @@ xtc_result xtc_project_validate(const xtc_project *project)
|
|||
}
|
||||
for (i = 0U; i < project->clip_count; ++i) {
|
||||
const xtc_clip_info *clip = project->clips + i;
|
||||
size_t path_length = 0U;
|
||||
while (path_length < XTC_ASSET_PATH_BYTES && clip->asset_path[path_length]) {
|
||||
unsigned char byte = (unsigned char)clip->asset_path[path_length++];
|
||||
if (byte < 32U || byte == 127U) return XTC_ERR_FORMAT;
|
||||
}
|
||||
if (path_length == XTC_ASSET_PATH_BYTES || (path_length && clip->asset_path[0] != '/')) return XTC_ERR_FORMAT;
|
||||
if (clip->id >= project->next_clip_id || track_index(project, clip->track_id) == SIZE_MAX ||
|
||||
!xtc_project_valid_name(clip->name) || !valid_range(clip->start_tick, clip->length_tick, clip->offset_tick, clip->source_length_tick)) return XTC_ERR_FORMAT;
|
||||
for (j = 0U; j < i; ++j) if (project->clips[j].id == clip->id) return XTC_ERR_FORMAT;
|
||||
}
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
xtc_result xtc_project_set_clip_asset(xtc_project *project, uint64_t id, const char *path)
|
||||
{
|
||||
size_t index, length = 0U, i;
|
||||
if (!project || !path) return XTC_ERR_INVALID_ARGUMENT;
|
||||
while (length < XTC_ASSET_PATH_BYTES && path[length]) ++length;
|
||||
if (length == XTC_ASSET_PATH_BYTES || (length && path[0] != '/')) return XTC_ERR_INVALID_ARGUMENT;
|
||||
for (i = 0; i < length; ++i)
|
||||
if ((unsigned char)path[i] < 32U || path[i] == 127) return XTC_ERR_INVALID_ARGUMENT;
|
||||
index = clip_index(project, id);
|
||||
if (index == SIZE_MAX) return XTC_ERR_NOT_FOUND;
|
||||
memmove(project->clips[index].asset_path, path, length + 1U);
|
||||
return XTC_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue