Posts

android - How can i use AudioTrack to play mp3 file and also seek to position -

iam trying develop application can set speed of music file(mp3) set 1x,1.5x,2x,2.5x this.but mediaplayer not support feauture unless 23 api.how can use audiotrack play mp3 file , seek position.the below code gives me "zzzzzzz" sound. public void playaudio(){ int minbuffersize = audiotrack.getminbuffersize(8000, audioformat.channel_configuration_mono, audioformat.encoding_pcm_16bit); int buffersize = 512; audiotrack = new audiotrack(audiomanager.stream_music, 8000, audioformat.channel_configuration_mono, audioformat.encoding_pcm_16bit, minbuffersize, audiotrack.mode_stream); string filepath = environment.getexternalstoragedirectory().getabsolutepath(); int = 0; byte[] s = new byte[buffersize]; try { final string path= environment.getexternalstoragedirectory().getabsolutepath() + "/folioreader/audio"+".mp3"; fileinputstream fin = new fileinputstream(path); data...

php - Upload file. After uploading will be save in the place where i have stated -

i upload docx location "c:\xammp\htdocs\fyp3\uploads/" below codes uploading file. now, after click on upload, cannot find file in given address. not sure error is. in advance:) if(isset($_files['file'])) { $file=$_files['file']; $file_name=$file['name']; $file_tmp = $file['tmp_name']; $file_size = $file['size']; $file_error = $file['error']; $file_ext = explode('.',$file_name); $file_ext = strtolower(end($file_ext)); $allowed=array('docx', 'jpg'); if(in_array($file_ext, $allowed)) { if($file_error === 0) { if($file_size <= 2097152) { $file_name_new = uniqid('', true) . '.' . $file_ext; $file_destination = "c:\xammp\htdocs\fyp...

raspberry pi - I2C between RPI and Arduino using Processing -

posted here code rpi master , arduino slave project. have analog sensor connected arduino , reading data processing on rpi. using processing because intend on generating graph , waveform data. code below seems work, however, slight movement of setup "disconnects" slave device because following message. "the device did not respond. check cabling , whether using correct address." have narrowed problem down , found out disconnects @ i2c.read(); function. question whether there type of break function when happen processing moves on , tries again in next iteration? or if stuck in loop waiting signal slave device? have suggestions on how approach this? processing code import processing.io.*; i2c i2c; int val = 0; void setup() { i2c = new i2c(i2c.list()[0]); } void draw () { if (i2c.list() != null) { i2c.begintransmission(0x04); i2c.write(8); byte[] in = i2c.read(1); int accel = in[0]; println (accel); } } arduino code #include <wire.h> #define sl...

python pandas - how to apply a normalise function to a dataframe column -

i have pandas dataframe, output similar below: index value 0 5.95 1 1.49 2 2.34 3 5.79 4 8.48 i want normalised value of each column['value'] , store in new column['normalised'] not sure how apply normalise function column... my normalising function this: (['value'] - min['value'])/(max['value'] - min['value'] i know should using apply or transform function add new column dataframe not sure how pass normalising function apply function... sorry if i'm getting terminology wrong i'm newbe python , in particular pandas! these pretty standard column operations: >>> (df.value - df.value.min()) / (df.value.max() - df.value.min()) 0 0.638054 1 0.000000 2 0.121602 3 0.615165 4 1.000000 name: value, dtype: float64 you can write df['normalized'] = (df.value - ....

android - Manually parse a portion of dynamic JSON object alongside Gson deserializer -

i want parse following json response dynamic json object, { "id": 1, "last_login": "2016-07-16t12:46:29.621996z", "point_of_sales": [ { "counter 4": { "type": "retail", "id": 6 } }, { "counter 5": { "type": "retail", "id": 7 } }, { "counter 6": { "type": "retail", "id": 8 } } ] } here objects name inside " point_of_sales " array dynamic makes difficult parse using gson. here's i've tried far, @serializedname("id") @expose private integer id; @serializedname("last_login") @expose private string lastlogin; @serializedname("point_of_sales") @expose private list<map<string, counter>> pointofsales = new arraylist<map<string, counter>>(); ...

python - matching a substring in a dateframe column -

i want match id column in dataframe if name contain string 'test_'. there simple way boolean vector df.id == 'something' df.id contains 'test_'. iiuc following should work: df.loc[df['id'].str.contains('test_'), 'id'] this return id's contain partial string if want boolean array against rows: df['id'].str.contains('test_')

Git reset in detached HEAD state -

i understand git reset command moves branch backwards in history (*), , branch moves 1 head pointing to. so got curious , tried call in detached head state see happen. expecting error git did something, , i'm unable figure out did. did git acted head still pointing before checked out , went detached head state ? [ edit 1 ] figured out. same when 1 not in detached head state, except doesnt move branch backward. it's the [ edit 2(*) ] git reset moves branch backward in history when specifying older commit. when doing git reset head , leaves branch (see comments below). git reset makes current branch , head move specific commit. if it's detached head, makes head move.