# HG changeset patch # User mas01cr # Date 1262709846 0 # Node ID 536cfa209e7f550d2861ba25a0cbebcd8bb38661 # Parent e7fae71ee67600d9d20f1215886ed9705224a3ba 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. diff -r e7fae71ee676 -r 536cfa209e7f audioDB.cpp --- 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; } diff -r e7fae71ee676 -r 536cfa209e7f sample.cpp --- 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)