commit 28/07/2025

This commit is contained in:
2025-07-28 16:33:41 +07:00
parent d12a089eda
commit 4f0a7a1560
6 changed files with 96 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import audio.AudioPlayer import audio.AudioPlayer
import content.ContentCache
import org.tinylog.Logger import org.tinylog.Logger
@@ -7,5 +8,6 @@ fun main() {
Logger.info("Application started" as Any) Logger.info("Application started" as Any)
val audioPlayer = AudioPlayer(44100) // 44100 Hz sampling rate val audioPlayer = AudioPlayer(44100) // 44100 Hz sampling rate
audioPlayer.InitAudio(1) audioPlayer.InitAudio(1)
val content = ContentCache()
} }

15
src/content/Category.kt Normal file
View File

@@ -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");
}

View File

@@ -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<SoundbankData>()
/**
* 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
}
}

16
src/content/Language.kt Normal file
View File

@@ -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"),;
}

View File

@@ -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)

13
src/content/VoiceType.kt Normal file
View File

@@ -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");
}