Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store sound files in the project and what solution to chose for storing references to them?

I'm making some fancy app which requires lot of short sounds for its use. Got few questions You might be able to answer.

  • Is there some restriction to the place I store then in the android project? Currently I put those in bin/res/sounds folder.

  • Is there a restriction to the format of files and is the .wav ok?

  • I'm gonna need something to store references to those sounds. I came up with a Dictionary which would consist of a sound name (key) and a path to the file so I could use in such method:

    mp = MediaPlayer.create(Test.this, R.raw.mysound);

How should I store R.raw.mysound, it's not a string right?

I apologize If i'm not quite clear about everything, I'm trying my best. Cheers

like image 720
Jacek Kwiecień Avatar asked Feb 06 '12 20:02

Jacek Kwiecień


People also ask

How do you store sound?

Sounds can be stored in digital form by using electronics to turn them into patterns of numbers. A CD stores music on its surface as a pattern of bumps. The bumps represent a coded pattern of numbers that the CD player turns back into sound waves.

Where are the sound files stored by default?

Open File Explorer or Windows Explorer and navigate to the following path: C:\Windows\Media. Scroll down past the folders until you see the individual sounds. Each sound is saved as a WAV file, which means you can play it in Windows Media Player or a similar audio player.

What are the various ways of storing the data of apps?

Internal storage, external storage, shared preferences, database, and shared storage are some of the storage options offered by Android.


1 Answers

Usually, you'll store sounds in the raw folder under your res folder (res/raw/mySound.wav). This tells the OS not to mess with it and just copy it over for you. Then you can use the line of code that you posted to load them in.

As for the .wav format that will work fine but it will be really large.

Have a look at what audio formats Android supports: http://developer.android.com/guide/appendix/media-formats.html

The reference (i.e. the R.raw.mySound) in an int. So you can just map some string to that int if you want but is that really easier than using the R.raw.mySound id?

like image 192
CaseyB Avatar answered Sep 26 '22 23:09

CaseyB