Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  distributing work-in-progress android projects  (Read 8376 times)
0 Members and 1 Guest are viewing this topic.
Offline philfrei
« Posted 2015-06-17 17:21:20 »

I've made a small program (two buttons: one turns on and off a synth tone, the other a "sound field" tool that generates chimes similar to a windchime). The code is a Java audio library combined with a "wrapper" I wrote to allow you to use the library in Android.

I was wondering about the possibility of getting feedback. I don't have any devices yet, am just working with the emulator. I'm wondering how much cpu the audio thread consumes on various devices, whether I'm keeping the efficiency high enough that it won't interfere with game graphics.

From reading various posts, it seems that if I simply post the "debug" apk, people will not be able to run it. Is this true? There is also a "debug-unaligned" apk that was generated automatically. I'm not sure how I did it, but I also have a "release-unsigned" apk made yesterday.  Clueless  This is the first time I started thinking about the actual process of making a release. With Java, making a jar is pretty straightforward and easy.

Is it really needed to create the signed certificate to do any distribution?

music and music apps: http://adonax.com
Offline Opiop
« Reply #1 - Posted 2015-06-17 17:29:22 »

As far as I know, no you don't need to sign the APK. That's only if you wish to distribute it on the Play Store. You can distribute the APK that your IDE generates and people who want to install your APK will have to enable an option in their developer settings on their phone to allow for third party applications (applications not installed through the Play Store). Is that what you're asking?
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 283
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #2 - Posted 2015-06-17 17:50:36 »

As always, the first question is: what happened when you tried?

Signing the APK is not a big deal- in fact eclipse can do it for you. You don't have to pay for a certificate or anything.

Post a link to the APK you're creating and we can try it out.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2015-06-18 00:22:00 »

Thanks!
 I am just getting started with this and didn't even know what to try! Very much a newbie with Android dev.

I have loaded the apk file to the following url:
http://hexara.com/androiddev/app-debug.apk

This is the file automatically generated by Android Studio, found in the directory:
[project name = AudioTest]/app/build/outputs/apk

It looked like creating a certificate, going through the signature process might not be such a big deal with Android Studio. But since it is new to me, and thus a mystery, I am not sure what complications might be involved. Does one have to be careful about picking various names and passwords, since one is encouraged to use the same certificate for the next 32 years or something like that? Questions like these make me want to bypass if possible for now and deal with them after a bit more research.

music and music apps: http://adonax.com
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 283
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #4 - Posted 2015-06-18 01:37:14 »

I just tried it and it works fine for me. The sounds play, although the one sound doesn't seem to stop when I push the button again.

I do have the "other sources" box checked in my security settings.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline philfrei
« Reply #5 - Posted 2015-06-18 02:47:30 »

[Edited]
@KevinWorkman -- Thanks for trying the app, and the instructions on loading 'debug' apks.

I'm also curious if there is a way you can judge how much cpu is being consumed while the "windchime" and the synth tone are playing. There are up to about a dozen sounds being generated and playing concurrently, when you consider the overlapping bells, though I have provisioned for 20 playing at once. My hope is to keep the consumption below 10% so that there is plenty room for graphics.

I can't seem to duplicate your error of the synth tone not turning off. The synth tone should completely die away after about a second or two at the most. Curious, now the 'WindChime' is causing a crash for me when turning it on a second time (after stopping it). [WindChime bug found, but haven't fixed/updated yet--will probably do tomorrow.]

Time for some debugging!

I think I have a lead on a device I can borrow. The fellow says a client gave it to him for dev testing on a project he was hired for, and that the client had bought it for $10 and then not signed up for the pricey phone service that was part of the deal. Sounds a little iffy, but I'm not clear if any actual laws were broken in the process.

music and music apps: http://adonax.com
Offline teletubo
Global Moderator

JGO Wizard


Medals: 75
Projects: 4
Exp: 8 years



« Reply #6 - Posted 2015-06-18 12:14:14 »

I have a Motorola Moto G android, which is not a powerful device.
The first time I ran it, as soon as I hit the "play" button the horn (?) sound started, but choppy. the sound would break ~ 2 times per second.
When I turned on the chimes it became a little worse, like 3 chops pers second. I tried to start/stop the sounds a few times, not sure if it really worked since the sound kept playing. after a few button presses I got a "force close".

I plugged in my usb and opened logcat and started it again. this time the first sound didn't chop at all, the choppiness started when I pressed the chime. After a few button presses I got this (sorry but logcat doesn't allow a simple ctrl c ctrl v):

Offline philfrei
« Reply #7 - Posted 2015-06-18 20:28:28 »

I fixed the error due to the ThreadPool being closed prematurely. (Error shown by teletubo.)

I didn't realize until just now that opiop65 message was saying the same thing as KevinWorkman explained about the 'other sources' box in the security settings. So thanks for that!

My reading comprehension level: iffy. It helps me a lot to have an example as well as a statement of general theory/purpose.

So far though, while I am excited the gist of the program runs, I don't understand the error (can't recreate) where the sustain tone refused to turn off. Also, I may have to scale back hopes, if the code I wrote is unable to run without hogging cpu, if it can run at all without dropouts. Maybe this library, as currently written, will only work with the most powerful Android devices, or only with future devices, as they come up to or exceed the performance standards of desk tops of the last couple years.

Is the following useful/interesting? Maybe I should post elsewhere (audio thread, or under its own subject). Here is the Android wrapper code I wrote for the library. OK to share. Maybe it can be edited to allow another library to work on Android, e.g., TinySound. It only covers playback, though, not loading of sound files. I haven't written that part yet.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
public class AudioWrapper {

    private CoreMixer coreMix;
    public final int FRAME_SIZE;
    public final int SAMPLE_RATE;
    private volatile boolean playing;
    private Thread t;

    public AudioWrapper(CoreMixer cm) {
        this.FRAME_SIZE = 4;
        this.SAMPLE_RATE = 44100;
        this.coreMix = cm;
    }

    public void start() throws IllegalStateException {
        if(this.playing) {
            throw new IllegalStateException("Already running.");
        } else {
            coreMix.prepareToGo();
            playing = true;

            AudioWrapper.FrameMixerPlayer mixerPlayer =
                    new AudioWrapper.FrameMixerPlayer();
            t = new Thread(mixerPlayer);
            t.start();
        }
    }

    public void stop() throws IllegalStateException {
        if(!this.playing) {
            throw new IllegalStateException("Already stopped.");
        } else {
            playing = false;
            coreMix.setToStop();

            try {
                t.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            t = null;
        }
    }

    private class FrameMixerPlayer implements Runnable {
        private FrameMixerPlayer() {}

        public void run() {

            int bufferSize = AudioTrack.getMinBufferSize(
                    SAMPLE_RATE,
                    AudioFormat.CHANNEL_OUT_STEREO,
                    AudioFormat.ENCODING_PCM_16BIT);

            AudioTrack audioTrack = new AudioTrack(
                    AudioManager.STREAM_MUSIC,
                    SAMPLE_RATE,
                    AudioFormat.CHANNEL_OUT_STEREO,
                    AudioFormat.ENCODING_PCM_16BIT,
                    bufferSize,
                    AudioTrack.MODE_STREAM);

            audioTrack.play();

            short[] samples = new short[bufferSize];

            float[] e = new float[2];
            int i = 0;

            while(AudioWrapper.this.playing) {
                while(i < bufferSize) {
                    e[0] = 0;
                    e[1] = 0;
                    coreMix.getFrame(e);
                    samples[i++] = (short)(e[0] * 32767);
                    samples[i++] = (short)(e[1] * 32767);
                }
                audioTrack.write(samples, 0, bufferSize);
                i = 0;
            }
            System.out.println("FrameMixerPlayer.run exiting");
        }
    }
}


AudioTrack is the Android class used for audio playback. In later implementations, other forms besides loading an array of Shorts has become possible. I've not tested yet which might be the fastest. The data from my end is currently -1 to 1 (floats).

The only link to my AudioLibrary is with the class I wrote called CoreMixer. An instance is passed in when the wrapper is instantiated.

The CoreMixer class exposes a read() method which returns a frame of sound. The read() can easily be altered to retrieve a full buffer's worth instead, depending on how the target audio library works. Perhaps I will try making that change in my library, though a lot of the functionality in it assumes working one frame at a time.
I also exposed prepareToGo() and setToStart() methods to handle some starting and cleanup chores in the library class.

music and music apps: http://adonax.com
Pages: [1]
  ignore  |  Print  
 
 

 
DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (555 views)
2018-03-24 14:43:53

Solater (94 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (338 views)
2018-03-02 22:15:33

buddyBro (998 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!