Closed

python code to java

This project received 5 bids from talented freelancers with an average bid price of $28 USD.

Get free quotes for a project like this
Project Budget
$10 - $30 USD
Total Bids
5
Project Description

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 Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online