Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sound() custom import

edited September 2012 in Questions Posts: 116

Can I import and play mp3 or wav or other sound files?

If not any synthetic voice?

Tagged:

Comments

  • No sorry :-((

  • Fix it!

    :-((

    Any plans down the road to add any mp3/midi or other formats?

  • SimeonSimeon Admin Mod
    Posts: 4,932

    You can construct custom sounds from raw sample data using the soundbuffer object — so in theory it is possible to play wav files. You would need to read the data in using the standard Lua io (from Dropbox, say) then push the data into a soundbuffer.

    It's not easy at the moment, but it is possible. We'd like to add an easy, more Codea-like solution for this in the future.

  • When the times perhaps I can get an example?

    For now I'll live without it. I am light years away from doing anything substantial.

    So much to learn, if only iPads and codea where around instead of my timex Sinclair when I started out.... .

  • The sound buffer thing is actually pretty easy because someone else already wrote it. There is a SoundData class that does what you are looking for--as long as you convert your audio to PCM 8 bit or 16 bit and DO NOT INCLUDE HEADERS.

  • While we are on the sound subject. I used the Sound Picker, in the Codea editor, to develop a custom sound. When I finished, it produced the following code:

    sound(DATA, "ZgNAKCF/f39/f387AACAPwAAAAD+itw+AABOQmkUEEEoADR/")
    

    This is good and it works in my test program. But now, I want to change the volume, interactively, in my routine. How do I do that with this series of characters?

    I saw, in the Sounds Plus sample program, there is a way to call sound() using parameters (i.e. sound({Waveform=waveform, AttackTime=math.pow(attackTime-0.5, 3), SustainTime=...etc.). Is there a way to convert the characters from the Sound Picker into individual parameters?

  • SimeonSimeon Admin Mod
    Posts: 4,932

    .@Ric_Esrey if I remember correctly, you can do this:

    sound(DATA, "ZgNAKCF/f39/f387AACAPwAAAAD+itw+AABOQmkUEEEoADR/", volume)
    

    Where volume is from 0 to 1.

    At the moment there is no built-in way to decode the string from the picker into a table of values. Although it is possible to encode a table of values into a string.

  • Posts: 384

    Hi @Ric_Esrey, Simeon is right, so as a work around to do what you describe (fiddle around with the sound once generated) I made and Herwig improved: Sound Slider

    http://twolivesleft.com/Codea/Talk/discussion/comment/5695#Comment_5695

    Hope that is useful to you.

  • Thanks @Simeon and @Fred. Very helpful. This forum is invaluable.

Sign In or Register to comment.