|
JP1 Remotes
|
View previous topic :: View next topic |
Author |
Message |
Johnson
Joined: 27 May 2014 Posts: 9 Location: china |
Posted: Tue May 27, 2014 8:21 pm Post subject: how to create nblibraries.properties |
|
|
Thx Barf.
When I ant the source, some errors occur, pls help me:
ant
Buildfile: /Volumes/back/project/sound/IrpMaster-src-1.0.0/build.xml
-antlr-pre-init:
-pre-init:
-init-private:
-pre-init-libraries:
-init-private-libraries:
-init-libraries:
BUILD FAILED
/Volumes/back/project/sound/IrpMaster-src-1.0.0/nbproject/build-impl.xml:63: Source resource does not exist: /Volumes/back/project/sound/IrpMaster-src-1.0.0/lib/nblibraries.properties
Total time: 0 seconds
Thx _________________ Lai |
|
Back to top |
|
|
Johnson
Joined: 27 May 2014 Posts: 9 Location: china |
Posted: Wed May 28, 2014 3:03 am Post subject: two source files |
|
|
Thx Barf.
Use ant, I get the two files.
If any progress, I let you know. _________________ Lai |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1415 Location: Munich, Germany |
Posted: Wed May 28, 2014 2:30 pm Post subject: |
|
|
Ok, now you can generate the missing, generated, files. You can just copy them to the source directory and tell Eclipse to compile all of the java files to am executable jar, with Main-Class to be org.harctoolbox.IrpMaster.IrpMaster.
nblibraries.properties is, as the name suggest, a NetBeans file.
If you decide to try to use NetBeans, I can upload the NetBeans project. |
|
Back to top |
|
|
Johnson
Joined: 27 May 2014 Posts: 9 Location: china |
Posted: Wed May 28, 2014 11:38 pm Post subject: android problem |
|
|
Hi Barf,
I use the play function in Android phone, but not work. The wave is similar, very very similar, but not match.
Pls take a look at my code
-----play() function -----
int sampleRateInHz = 44100;
int channelConfig =2 ;
int audioFormat = AudioFormat.ENCODING_PCM_8BIT; // pcm_8_bit
Log.e(TAG, " buf len:" + buf.length ); // output: buf len:10998
AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 44100,
AudioFormat.CHANNEL_OUT_STEREO,
audioFormat, buf.length, AudioTrack.MODE_STATIC);
at.write(buf, 0, buf.length);
at.play();
Log.e(TAG, " StreamType:" + at.getStreamType() +
" SampleRate:" + at.getSampleRate() +
" channelConfig:" + at.getChannelConfiguration() );
// output: StreamType:3 SampleRate:44100 channelConfig:12
---------
The buf variable is from" Wave(double freq, double[] data,int sampleFrequency, int sampleSize, int channels, boolean bigEndian,
boolean omitTail, boolean square, boolean divide) "
Thanks Barf.
How to upload the images? I screenshot the wave images _________________ Lai |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1415 Location: Munich, Germany |
Posted: Thu May 29, 2014 1:54 pm Post subject: |
|
|
Please import the file you have generated to IrScrutinizer (on a tested platform). (File -> Import -> Import as single sequence -> Wave.) It will analyze the imported file to the console.
Creating a sane wave file is the first step. Having your hardware "shooting" it the next. |
|
Back to top |
|
|
Johnson
Joined: 27 May 2014 Posts: 9 Location: china |
Posted: Fri May 30, 2014 3:23 am Post subject: work in Android |
|
|
It works now. _________________ Lai |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1415 Location: Munich, Germany |
Posted: Fri May 30, 2014 10:13 am Post subject: |
|
|
Nice.
It would be interesting to know how you solved the problems, in particular if you replaced some of "my" classes with something else for Android. (Just got my shiny new Xperia Z2 an hours ago ) |
|
Back to top |
|
|
Johnson
Joined: 27 May 2014 Posts: 9 Location: china |
Posted: Tue Jun 03, 2014 9:02 pm Post subject: wav in android |
|
|
I change some codes, include the wav header
----
public Wave(double freq, double[] data, int sampleFrequency,
int sampleSize, int channels, boolean bigEndian, boolean omitTail,
boolean square, boolean divide) {
// if (data == null || data.length == 0)
// throw new
// IncompatibleArgumentException("Cannot create wave file from zero array.");
double sf = ((double) sampleFrequency) / 1000000.0;
this._sampleRate = sampleFrequency;
int[] durationsInSamplePeriods = new int[omitTail ? data.length - 1
: data.length];
int length = 0;
for (int i = 0; i < durationsInSamplePeriods.length; i++) {
durationsInSamplePeriods[i] = (int) Math.round(Math.abs(sf
* data[i]));
length += durationsInSamplePeriods[i];
}
double c = ((double) sampleFrequency) / ((double) freq);
buf = new byte[length * sampleSize / 8 * channels + 44];
byte[] header = { 82, 73, 70, 70, -118, 43, 0, 0, 87, 65, 86, 69, 102,
109, 116, 32, 16, 0, 0, 0, 1, 0, 2, 0, 68, -84, 0, 0, -120, 88,
1, 0, 2, 0, 8, 0, 100, 97, 116, 97, 102, 43, 0, 0 };
System.arraycopy(header, 0, buf, 0, header.length);
int index = 44;
for (int i = 0; i < data.length - 1; i += 2) {
// Handle pulse, even index
for (int j = 0; j < durationsInSamplePeriods[i]; j++) {
double t = ((double) j) / (divide ? 2 * c : c);
double fraq = t - (int) t;
double s = square ? (fraq < 0.5 ? -1.0 : 1.0) : Math.sin(2
* Math.PI * (fraq));
if (sampleSize == 8) {
int val = (int) Math.round(Byte.MAX_VALUE * s);
buf[index++] = (byte) ((byte) val + 0x80);
if (channels == 2)
buf[index++] = (byte) ((byte) -val + 0x80);
} else {
int val = (int) Math.round(Short.MAX_VALUE * s);
byte low = (byte) ((byte) (val & 0xFF) + 0x80);
byte high = (byte) ((byte) (val >> 8) + 0x80);
buf[index++] = bigEndian ? high : low;
buf[index++] = bigEndian ? low : high;
if (channels == 2) {
val = -val;
low = (byte) ((byte) (val & 0xFF) + 0x80);
high = (byte) ((byte) (val >> 8) + 0x80);
buf[index++] = bigEndian ? high : low;
buf[index++] = bigEndian ? low : high;
}
}
}
// Gap, odd index
if (!omitTail || i < data.length - 2) {
for (int j = 0; j < durationsInSamplePeriods[i + 1]; j++) {
for (int ch = 0; ch < channels; ch++) {
buf[index++] = (byte) (0 + 0x80);
if (sampleSize == 16)
buf[index++] = (byte) (0 + 0x80);
}
}
}
}
// audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
// sampleFrequency, sampleSize, channels, sampleSize/8*channels,
// sampleFrequency, bigEndian);
// update wav filesize
byte fileb[] = int2Byte(buf.length - 8);
buf[4] = fileb[3];
buf[5] = fileb[2];
buf[6] = fileb[1];
buf[7] = fileb[0];
}
----- _________________ Lai |
|
Back to top |
|
|
Barf Expert
Joined: 24 Oct 2008 Posts: 1415 Location: Munich, Germany |
Posted: Fri Jun 20, 2014 2:19 pm Post subject: |
|
|
Version 1.0.1. has been released. As before, there is only a source distribution, available at my web site, see documentation.
There are a few bug fixes and a few changes to the API, nothing dramatic. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|