diff --git a/src/Main.kt b/src/Main.kt index d25d777..17a07c1 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,4 +1,5 @@ import audio.AudioPlayer +import content.ContentCache import org.tinylog.Logger @@ -7,5 +8,6 @@ fun main() { Logger.info("Application started" as Any) val audioPlayer = AudioPlayer(44100) // 44100 Hz sampling rate audioPlayer.InitAudio(1) + val content = ContentCache() } diff --git a/src/content/Category.kt b/src/content/Category.kt new file mode 100644 index 0000000..6bb0af3 --- /dev/null +++ b/src/content/Category.kt @@ -0,0 +1,15 @@ +package content + +@Suppress("unused") +enum class Category(name: String) { + AirlineCode("Airline_Code"), + AirplaneName("Airplane_Name"), + AlphabetNumeric("AlphabetNumeric"), + City("City"), + Phrase("Phrase"), + Places("Places"), + PlatNomor("PlatNomor"), + Shalat("Shalat"), + Year("Year"), + Birthday("Birthday"); +} \ No newline at end of file diff --git a/src/content/ContentCache.kt b/src/content/ContentCache.kt new file mode 100644 index 0000000..5e3e0e7 --- /dev/null +++ b/src/content/ContentCache.kt @@ -0,0 +1,44 @@ +package content + +import audio.AudioFileInfo + +/** + * Class to manage loaded content in the application. + * This class provides methods to retrieve and add soundbank data based on specific criteria. + */ +@Suppress("unused") +class ContentCache { + val contentList = ArrayList() + + /** + * Get the specified SoundbankData from tag, category, language, and voiceType. + * @return SoundbankData if found, null otherwise. + */ + fun Get(tag: String, category: Category, language: Language, voiceType: VoiceType): SoundbankData? { + + return contentList.find { it -> + it.TAG == tag && + it.Category == category && + it.Language == language && + it.VoiceType == voiceType && + it.audio.isValid() + } + } + + /** + * Adds a new soundbank to the content list if it does not already exist. + * + * @param tag The unique identifier for the soundbank. + * @param category The category of the soundbank. + * @param language The language of the soundbank. + * @param voiceType The voice type of the soundbank. + * @param audio The audio file information for the soundbank. + * @return True if the soundbank was added, false if it already exists. + */ + fun Add(tag: String, category: Category, language: Language, voiceType: VoiceType, audio: AudioFileInfo): Boolean { + val existing = Get(tag, category, language, voiceType) + if (existing!=null) return false + contentList.add(SoundbankData(tag, category, language, voiceType, audio)) + return true + } +} \ No newline at end of file diff --git a/src/content/Language.kt b/src/content/Language.kt new file mode 100644 index 0000000..0274b87 --- /dev/null +++ b/src/content/Language.kt @@ -0,0 +1,16 @@ +package content + +/** + * Enum class representing different languages. + * + * @property name The name of the language, as in Soundbank Database + */ +@Suppress("unused") +enum class Language(name: String) { + Indonesia("INDONESIA"), + English("ENGLISH"), + Local("LOCAL"), + Japanese("JAPANESE"), + Chinese("CHINESE"), + Arabic("ARABIC"),; +} \ No newline at end of file diff --git a/src/content/SoundbankData.kt b/src/content/SoundbankData.kt new file mode 100644 index 0000000..8e63ccd --- /dev/null +++ b/src/content/SoundbankData.kt @@ -0,0 +1,6 @@ +package content + +import audio.AudioFileInfo + +@Suppress("unused") +data class SoundbankData(val TAG: String, val Category: Category, val Language: Language, val VoiceType: VoiceType, val audio: AudioFileInfo) diff --git a/src/content/VoiceType.kt b/src/content/VoiceType.kt new file mode 100644 index 0000000..639f46d --- /dev/null +++ b/src/content/VoiceType.kt @@ -0,0 +1,13 @@ +package content + +/** + * Enum class representing different voice types. + * + * @property voicename The name of the voice type. + */ +@Suppress("unused") +enum class VoiceType(voicename: String) { + Voice1("VOICE_1"), + Voice2("VOICE_2"), + Voice3("VOICE_3"); +} \ No newline at end of file