IrpMaster, program/library for IRP rendering, released

Discussion forum for JP1 software tools currently in use, or being developed, such as IR, KM, RemoteMaster, and other misc apps/tools.

Moderator: Moderators

Johnson
Posts: 9
Joined: Tue May 27, 2014 3:08 am
Location: china

how to create nblibraries.properties

Post by Johnson »

Thx Barf. :D

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
Johnson
Posts: 9
Joined: Tue May 27, 2014 3:08 am
Location: china

two source files

Post by Johnson »

Thx Barf.
Use ant, I get the two files.
If any progress, I let you know.
Lai
Barf
Expert
Posts: 1524
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

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.
Johnson
Posts: 9
Joined: Tue May 27, 2014 3:08 am
Location: china

android problem

Post by Johnson »

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
Barf
Expert
Posts: 1524
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

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.
Johnson
Posts: 9
Joined: Tue May 27, 2014 3:08 am
Location: china

work in Android

Post by Johnson »

:D It works now.
Lai
Barf
Expert
Posts: 1524
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

Nice. 8-)

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 :wink: )
Johnson
Posts: 9
Joined: Tue May 27, 2014 3:08 am
Location: china

wav in android

Post by Johnson »

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 = (int) Math.round(Math.abs(sf
* data));
length += durationsInSamplePeriods;
}

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; 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
Barf
Expert
Posts: 1524
Joined: Fri Oct 24, 2008 1:54 pm
Location: Munich, Germany
Contact:

Post by Barf »

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.
Post Reply