Mercurial > hg > audiodb
changeset 659:536cfa209e7f
Sampling enhancements
Allow specification of a key with -k for doing sampling between a single
datum and the rest of the database. (The implementation is slightly
icky, as mentioned in the previous commit message; hopefully this
situation will not remain for too long).
While we're at it, allow -r/--resultlength as a synonym for --nsamples
(if --nsamples is not given) in order better to reflect the analogy
between querying and sampling.
author | mas01cr |
---|---|
date | Tue, 05 Jan 2010 16:44:06 +0000 |
parents | e7fae71ee676 |
children | 98db3bff21a0 |
files | audioDB.cpp sample.cpp |
diffstat | 2 files changed, 29 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Tue Jan 05 16:44:03 2010 +0000 +++ b/audioDB.cpp Tue Jan 05 16:44:06 2010 +0000 @@ -332,7 +332,19 @@ if(sequenceLength < 1 || sequenceLength > 1000) { error("seqlen out of range: 1 <= seqlen <= 1000"); } - nsamples = args_info.nsamples_arg; + if(args_info.nsamples_given) { + nsamples = args_info.nsamples_arg; + } else if(args_info.resultlength_given) { + nsamples = args_info.resultlength_arg; + } else { + nsamples = args_info.nsamples_arg; + } + if(args_info.key_given) { + query_from_key = true; + key = args_info.key_arg; + } + + return 0; }
--- a/sample.cpp Tue Jan 05 16:44:03 2010 +0000 +++ b/sample.cpp Tue Jan 05 16:44:06 2010 +0000 @@ -92,8 +92,23 @@ double sumdist = 0; double sumlogdist = 0; + unsigned key_index = 0; + if(query_from_key) { + /* naughty use of internals here. When this is part of the API, + it will be a legitimate use of internals. -- CSR, + 2010-01-05 */ + key_index = (*adb->keymap)[key]; + if(propTable[key_index] == 0) { + error("no samples of this length possible for key"); + } + } for (unsigned int i = 0; i < nsamples;) { - unsigned track1 = random_track(propTable, total); + unsigned track1 = 0; + if(query_from_key) { + track1 = key_index; + } else { + track1 = random_track(propTable, total); + } unsigned track2 = random_track(propTable, total); if(track1 == track2)