python code to java

Closed

pure and simple, just convert this code to java, we shall validate it if the code works properly. if not, no payment.

#!/usr/bin/python

import numpy as N

import wave

import sys

class IrSoundFile:

def __init__( self, make, model, signal ):

[url removed, login to view] = 0

dir = make + '/' + model

#`mkdir -p $dir`

[url removed, login to view] = [url removed, login to view]( dir + '/' + signal + '.wav', 'wb' )

[url removed, login to view] = []

def write_data(self):

data_str = ''.join([url removed, login to view])

[url removed, login to view]( ( 2, 2, self.base_frequency, len( data_str ), 'NONE', 'noncompressed' ) )

[url removed, login to view](data_str)

def close(self):

[url removed, login to view]()

def add_vals(self, count, val):

counter = 0

half_base = self.base_frequency / 2

while counter < count:

if val == 1:

ir_val = 0xFF7F

if [url removed, login to view] > ( half_base ):

ir_val = 0xFFFF - ir_val

else:

ir_val = 0x7FFF

#print( "IR_VAL: %d" % ( ir_val ) )

[url removed, login to view]( [url removed, login to view]( '>H', ir_val ) ) # left channel

[url removed, login to view]( [url removed, login to view]( '>H', ir_val ) ) # right channel

old_shift = [url removed, login to view]

[url removed, login to view] += [url removed, login to view]

if [url removed, login to view] > self.base_frequency: # I guess this is faster than %

[url removed, login to view] = [url removed, login to view] - self.base_frequency

if not ( ( old_shift < half_base ) and ( [url removed, login to view] < half_base ) or ( old_shift > half_base ) and ( [url removed, login to view] > half_base ) ):

counter += 1

def add_pairs( self, ones, zeros ):

self.add_vals( int( ones, 16 ), 1 )

self.add_vals( int( zeros, 16 ), 0 )

[url removed, login to view]( "%s %s | " % ( ones, zeros ) )

def write_ir_code( self, str ):

self.base_frequency = 44100 # the freq of the wav file

frequencies = { '006d' : 38200 / 2 } # IR freq / 2 (b/c we're using 2 of those)

codes = [url removed, login to view]( ' ' )

( [url removed, login to view], sequence_1_len, sequence_2_len ) = ( frequencies[codes[1]], int( codes[2], 16 ), int( codes[3], 16 ) )

print "S1L:%d S2L:%d FRQ:%d BFRQ:%d" % ( sequence_1_len, sequence_2_len, [url removed, login to view], self.base_frequency)

print "Writing sequence 1 240 times"

for j in range( 1, 4 ):

for i in range( 1, sequence_1_len + 1 ):

self.add_pairs( codes[i * 2 + 2], codes[i * 2 + 1 + 2] )

print "\nWriting sequence 2 one time"

for j in range( 1, 1 ):

for i in range( 1, sequence_2_len + 1 ):

self.add_pairs( codes[i * 2 + 2 + sequence_1_len], codes[i * 2 + 1 + 2 + sequence_1_len] )

print ""

self.write_data()

Skills: Java, Python

See more: Python Java, python code java code, java code python, python writing to file, print writing, print pack, java shift, java data struct, data str, convert python code to java, convert java code to c, python to java, python numpy, d python, code sys, val, str, python java c++, len, java python, d model print, code java, c python java, code wav file, split wav file

Project ID: #5033460

5 freelancers are bidding on average $28 for this job

poornachand

I CAN DO THIS VERY EASILY.

$30 USD in 2 days
(37 Reviews)
5.6
sousivw

This is the class and its constructor just for a start. The rest of the code if I get the project. However I will need a better version of the python code as python code depends on its format and this code is not forma More

$30 USD in 3 days
(1 Review)
1.0
plorio

The only limiting factor is finding a substitute for the python wave module. If picked, I'll need the python code formatted as the one you supplied will not suffice.

$25 USD in 3 days
(0 Reviews)
0.0
MartinMunoz

I can do this, I know python programming. But, Can you send to me the python code with the correct indentation?

$25 USD in 3 days
(0 Reviews)
0.0
Carlangueitor

Hello! I just need an example of input and expected output of this program. If program doesn't works, I fix the program.

$30 USD in 3 days
(0 Reviews)
0.0