summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/decoder_template.c38
-rw-r--r--examples/dsp_template.c6
2 files changed, 24 insertions, 20 deletions
diff --git a/examples/decoder_template.c b/examples/decoder_template.c
index b6e6585b..8d7c5a24 100644
--- a/examples/decoder_template.c
+++ b/examples/decoder_template.c
@@ -18,7 +18,6 @@ typedef struct {
} example_info_t;
static const char * exts[] = { "example", NULL }; // e.g. mp3
-static const char *filetypes[] = { "example", NULL }; // e.g. MP3
// allocate codec control structure
static DB_fileinfo_t *
@@ -106,13 +105,16 @@ example_seek (DB_fileinfo_t *_info, float time) {
// return NULL on failure
static DB_playItem_t *
-example_insert (DB_playItem_t *after, const char *fname) {
+example_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
// open file
DB_FILE *fp = deadbeef->fopen (fname);
if (!fp) {
trace ("example: failed to fopen %s\n", fname);
return NULL;
}
+
+ // decoder_* functions are imaginary -- you should replace them with real
+ // decoder library calls
decoder_info_t *di = decoder_open ();
if (!di) {
trace ("example: failed to init decoder\n");
@@ -126,11 +128,22 @@ example_insert (DB_playItem_t *after, const char *fname) {
return NULL;
}
+ // replace "example" with your file type (e.g. MP3, WAV, etc)
+ const char *ft = "example";
+
+ // no cuesheet, prepare track for addition
+ DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id);
+
+ deadbeef->pl_replace_meta (it, ":FILETYPE", ft);
+ deadbeef->plt_set_item_duration (plt, it, (float)ti.total_num_samples/ti.samplerate);
+
// now we should have track duration, and can try loading cuesheet
// 1st try embedded cuesheet
if (ti.embeddedcuesheet[0]) {
- DB_playItem_t *cue = deadbeef->pl_insert_cue_from_buffer (after, fname, ti.embeddedcuesheet, strlen (ti.embeddedcuesheet), &plugin, plugin.filetypes[0], ti.total_num_samples, ti.samplerate);
+ DB_playItem_t *cue = deadbeef->plt_insert_cue_from_buffer (plt, after, it, ti.embeddedcuesheet, strlen (ti.embeddedcuesheet), ti.total_num_samples, ti.samplerate);
if (cue) {
+ deadbeef->pl_item_unref (it);
+ deadbeef->pl_item_unref (cue);
// cuesheet loaded
decoder_free (di);
return cue;
@@ -138,19 +151,15 @@ example_insert (DB_playItem_t *after, const char *fname) {
}
// embedded cuesheet not found, try external one
- DB_playItem_t *cue = deadbeef->pl_insert_cue (after, fname, &plugin, plugin.filetypes[0], ti.total_num_samples, ti.samplerate);
+ DB_playItem_t *cue = deadbeef->plt_insert_cue (plt, after, it, ti.total_num_samples, ti.samplerate);
if (cue) {
// cuesheet loaded
+ deadbeef->pl_item_unref (it);
+ deadbeef->pl_item_unref (cue);
decoder_free (di);
return cue;
}
- // no cuesheet, prepare track for addition
- DB_playItem_t *it = deadbeef->pl_item_alloc ();
- it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id);
- it->fname = strdup (fname);
- it->filetype = filetypes[0];
- deadbeef->pl_set_item_duration (it, (float)ti.total_num_samples/ti.samplerate);
// add metainfo
if (!strlen (ti.title)) {
@@ -167,7 +176,7 @@ example_insert (DB_playItem_t *after, const char *fname) {
decoder_free (di);
// now the track is ready, insert into playlist
- after = deadbeef->pl_insert_item (after, it);
+ after = deadbeef->plt_insert_item (plt, after, it);
deadbeef->pl_item_unref (it);
return after;
}
@@ -196,10 +205,9 @@ static DB_decoder_t plugin = {
.plugin.version_minor = 1,
.plugin.type = DB_PLUGIN_DECODER,
.plugin.name = "short plugin name",
+ .plugin.id = "example",
.plugin.descr = "plugin description",
- .plugin.author = "author name",
- .plugin.email = "author email",
- .plugin.website = "author/plugin website",
+ .plugin.copyright = "copyright message - author(s), license, etc",
.plugin.start = example_start,
.plugin.stop = example_stop,
.init = example_init,
@@ -209,8 +217,6 @@ static DB_decoder_t plugin = {
.seek_sample = example_seek_sample,
.insert = example_insert,
.exts = exts,
- .id = "example",
- .filetypes = filetypes
};
DB_plugin_t *
diff --git a/examples/dsp_template.c b/examples/dsp_template.c
index 24b53759..d78d7531 100644
--- a/examples/dsp_template.c
+++ b/examples/dsp_template.c
@@ -51,7 +51,7 @@ example_reset (ddb_dsp_context_t *ctx) {
}
int
-example_process (ddb_dsp_context_t *ctx, float *samples, int nframes, ddb_waveformat_t *fmt) {
+example_process (ddb_dsp_context_t *ctx, float *samples, int nframes, int maxframes, ddb_waveformat_t *fmt, float *r) {
ddb_example_t *example = (ddb_example_t *)ctx;
for (int i = 0; i < nframes*fmt->channels; i++) {
samples[i] *= example->level;
@@ -115,9 +115,7 @@ static DB_dsp_t plugin = {
.plugin.id = "example",
.plugin.name = "example",
.plugin.descr = "example DSP Plugin",
- .plugin.author = "",
- .plugin.email = "",
- .plugin.website = "",
+ .plugin.copyright = "copyright message - author(s), license, etc",
.num_params = example_num_params,
.get_param_name = example_get_param_name,
.set_param = example_set_param,