From cb98143f340b80e3860fc259671c566ba7518401 Mon Sep 17 00:00:00 2001 From: nishi Date: Tue, 14 May 2024 03:53:26 +0000 Subject: [PATCH] add ksynth_get_revision git-svn-id: file:///raid/svn-main/kazu-ksynth/trunk@41 7b47e76f-e598-2f43-bc14-414d160cc389 --- src/ksynth.c | 17 +++++++++++++++-- src/ksynth.h | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/ksynth.c b/src/ksynth.c index 733e907..585cc9a 100644 --- a/src/ksynth.c +++ b/src/ksynth.c @@ -132,8 +132,22 @@ struct Sample** int_allocate_samples(const char* path, unsigned char keys, struc return NULL; } -int ksynth_get_revision(void){ +int ksynth_get_revision(void) { const char* rev = "$Rev$"; + int n = 0; + bool found = false; + + for(int i = 0; rev[i] != 0; i++) { + if(rev[i] >= '0' && rev[i] <= '9') { + found = true; + n *= 10; + n += rev[i] - '0'; + } else if(found) { + /* non-number char after number */ + break; + } + } + if(!found) return -1; return n; } @@ -244,7 +258,6 @@ void ksynth_note_off(struct KSynth* ksynth_instance, unsigned char channel, unsi } } - void ksynth_note_off_all(struct KSynth* ksynth_instance) { if(ksynth_instance != NULL) { for(unsigned long i = 0; i < ksynth_instance->max_polyphony; ++i) { diff --git a/src/ksynth.h b/src/ksynth.h index 8534920..8de4a61 100644 --- a/src/ksynth.h +++ b/src/ksynth.h @@ -40,6 +40,23 @@ struct KSynth { struct Voice** voices; }; +/** + * @~english + * @brief Returns the revision of the KSynth. + * + * This function returns the revision of the KSynth. + * + * @return Revision of the KSynth, returns -1 on fail. + * + * @~japanese + * @brief KSynthのリビジョンを返します。 + * + * この関数はKSynthのリビジョンを返します。 + * + * @return KSynthのリビジョン、失敗時には-1 + */ +int ksynth_get_revision(void); + /** * @~english * @brief Creates a new KSynth instance. -- 2.43.0