• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

SoundText (and WavData)

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Hi

Ive been playing with getting Sounds queued, and came up with SoundText.
Sound text allows you to assign a word to a Sound, and then you can play a phrase based on the individual words.

WavData is also required as part of SoundText. WavData reads the Wav file length in millisecs. All modules are native to CX and should work on all targets.

Repos here WavData SoundText

Demo here https://richpantson.itch.io/soundtext

example (from SoundText repo)
Cerberus:
Strict

Import mojo2
Import soundtext

Class myClass Extends App
    Field cnvs:Canvas

    Method OnCreate:Int()
        SetUpdateRate(60)             
        cnvs = New Canvas
      
        LoadSoundText("player","player.wav")
        LoadSoundText("one","one.wav")
        LoadSoundText("two","two.wav")
        LoadSoundText("requires","requires.wav")
        LoadSoundText("ammo","ammo.wav")
        LoadSoundText("health","health.wav")
        LoadSoundText("keys","keys.wav")
      
        Return 0
    End
  
    Method OnUpdate:Int()
        UpdateSoundText()
        If KeyHit(KEY_SPACE) Or MouseHit(MOUSE_LEFT)
            Local player:String = (["one","two"])[Rnd(2)]
            Select Int(Rnd(3))
            Case 1
                PlaySoundText("player "+player+" requires health")
            Case 2
                PlaySoundText("player "+player+" requires ammo")
            Default
                PlaySoundText("player "+player+" requires keys")
            End
        End
        Return 0
    End
  
    Method OnRender:Int()
        cnvs.Clear (0,0.2,0) 
        cnvs.SetColor (0,0.8,0) 
        cnvs.DrawText( String("SoundText demo~nHit screen for random phrase").Split("~n")),DeviceWidth()/2,DeviceHeight()/2,0.5,0.5
        cnvs.Flush

        Return 0
    End
End

Function Main:Int()
    New myClass     
    Return 0
End
 
Last edited:
Back
Top Bottom