How can I extract the two channels from a stereo track?

Hi,
I am writing a class that is able to draw an audio signal. It seems to be working well but I have a question. If I load a mono audio file I am able to draw it on a graph by using the byte[] array and everything is ok until now. That's the code:
void Draw(byte[] x)
            Graphics g=getGraphics();
            Graphics2D g2=(Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                     RenderingHints.VALUE_ANTIALIAS_ON);
            for(int i=0; i<x.length-6; i++)
                g2.draw(new Line2D.Float(((i*(getWidth()-6))/x.length)+5, (getHeight()/2)-          ((x*(getWidth()-6))/x.length), (((i+1)*(getWidth()-6))/x.length)+5, (getHeight()/2)-     ((x[i+1]*(getWidth()-6))/x.length)));
The results is correct only if I have a mono track. Obviously when I get a stereo track the array becomes very large so here the question. How can I extract the two audio channels from a stereo track?
Thanks in advance.
Maurizio Di Vitto                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

A mono audio stream is stored [sample, sample, sample, sample], so just a list of samples in an array.
A stereo sample is interleaved in the same manner, so you get [left-sample, right-sample, left-sample, right-sample]
So every nth sample is the 1st channel, every nth+1 is the 2nd channel...

Similar Messages

  • How can i extract the particular data from Base tables

    Hi
    I have some Base R/3- Tables . I need to exact the data from these base tables.
    But i need to select some type of datarecords(eg: select Material Documents from MSEG and MKPF tables based on movement types 261,262).
    Something like that . So how can i select the particular category datarecords from base tables. Anyway im going to create the Custom DataSource.
    So please let me know . how can i extarct tha particular data from base tables
    kumar

    Hi Venkat
    See i have some 5-tables . I need to extarct from these tables.
    first i need to extract the data from one table fully.
    Then i need to extarct the data from second table based on profict centers, company codes of first table.
    Then i need to extract the data from third table based on profict centers of first table and movement type = 2p,2n,2s condition.
    So how can i extarct like this data from multiple tables.
    Please let me know
    kumar

  • How can I extract the Thunderbird emails from the hard disk retrieved from a broken laptop ?

    My laptop died but I could remove its hard disk and it is intact
    I have placed the disk in an external USB drive
    I have a new laptop and I have installed Thunderbird
    I wish to retrive the emails stored on the old hard
    I wish to store them in Archive folders on my new Thunderbird installation on my new laptop
    Please advise me on how I can do this
    Thank you

    Your old messages, and much else, are stored in the profile. Move this to your new machine.
    https://support.mozilla.org/en-US/kb/profiles-tb

  • HT4436 Why is my daughter receiving my text messages on her itouch when I send them from my iphone? We are both on icloud so how can I separate the two? Do I need another icould or apple account??

    Why is my daughter receiving my text messages on her itouch when I send them from my iphone? We are both on icloud so how can I separate the two? Do I need another icould or apple account??

    It's happening because you are using the same Apple ID for iMessage.  You don't need to do anything with your iCloud account to fix this.  You should create a separate Apple ID for her device to use with iMessage and FaceTime.  (You can continue to share the same ID for purchasing from the iTunes and App stores if you wish; it doesn't need to be the same as the ID you use for other services.)  Once you've done this, on her device go to Settings>Messages>Send & Receive, tap the ID, sign out, then sign back in with the new ID.  Do the same thing in Settings>FaceTime.
    Another caution is that if you share and iCloud account with her, any data you both sync with the account such as contacts, will be merged and the merged data will appear on both devices.  If you don't want to end up with each other's contacts, calendars, etc. on your devices, you should have separate iCloud accounts to.  If you want to make this change, go to Settings>iCloud on her device and tap Delete Account.  (This only deletes the account from the device, not from iCloud.)  When prompted about what to do with the iCloud data be sure to choose Keep On My iPod.  Then set up a new iCloud account with her new ID, turn on iCloud data syncing again, and when prompted choose Merge.

  • How can I extract the data from Xstring .

    Hi Gurus ,
    How can I extract the data from a XSTRING  .
    I have to get the data which is filled in the survey form the data is getting saved in form of xstring .
    Someone told me that there is a standard FM for that . but I am not able to find .
    Please reply with the FM in case some one knows about it .
    Thanks in advance .

    The following code works as of 7.0 (in any SAP system):
    FORM XSTRING_TO_STRING USING input TYPE xstring CHANGING output TYPE string.
    TYPES : BEGIN OF ty_struc,
              line TYPE c LENGTH 100,
            END OF ty_struc.
    DATA lt_char TYPE TABLE OF ty_struc.
    DATA length TYPE i.
    length = xstrlen( input ) / cl_abap_char_utilities=>charsize.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer                = input
      tables
        binary_tab            = lt_char.
    CONCATENATE LINES OF lt_char INTO output RESPECTING BLANKS.
    output = output(length).
    ENDFORM.
    Edited by: Sandra Rossi on Mar 30, 2010 12:24 AM

  • HT204150 After upgrading to Windows 8, in my Outlook 2007 Contacts I now have "Contacts in iCloud" and "Contacts from iCloud".   How can I merge the two into one Contacts list.

    After upgrading to Windows, in my Outlook 2007 Contacts I now have "Contacts in iCloud"  plus "Contacts from iCloud".  How can I merge the two to avoid duplication.

    Hi Ingo 2711,
    Thank you for your suggestion.  I backup on itunes. I went to itunes, deleted syncing my contacts, then re-synced them. But the Facetime capability option continues to be there on most (not all, for some curious reason) of my contacts. I am not sure I posed my question correctly.  I want to be able to FT with my family, so don't want to delete the FT capability totally from my iphone and ipad. But I don't want all these other iphone calls from various contacts to ring on my ipad as FT calls.  I want a way to select with whom I have FT capabilities. Any further suggestions? Thanks much, trekpal

  • How can I extract the info from my Time Capsule?

    How can I extract the info from my Time Capsule?

    What info would that be??
    If you mean how to recover TM back to a computer.. see Pondini Q14-17
    http://pondini.org/TM/FAQ.html
    If that isn't it .. we do not know what.. "the info" you are talking about.

  • How can I extract the soundtrack from iMovie and put it in my iTunes Library?

    How can I extract the soundtrack from iMovie and put it in my iTunes Library?

    Or this
    From iMovie 10.0.6 select Share > File. Then select Format=Audio Only. Then select File Format and choose from AAC,MP3,AIFF or WAV.

  • HT4356 I  from an iPad , but get, " no AirPrint printers found" , how can I connect the two devices?(I have followed all the usual network steps!

    I  am trying to airprint from an iPad , but get, " no AirPrint printers found" , how can I connect the two devices?(I have followed all the usual network steps!

    Make sure you have a AirPrint enabled printer.
    http://support.apple.com/kb/ht4356

  • How can I output the alpha channel in Premiere elements 10

    How can I output the alpha channel in Premiere elements 10. What format should I use?
    Tried outputting to an AVI filet but the file did not contain an alpha channel that After Effects 5.5 would recognize.

    Bill,
    I hope you ordered 32 GB or more on that new computer After Effects 5.5 takes up as much as it can.
    The Roto Brush tool is really a timesaver over ordinary Rotoscoping. Although, my problem now is: when I try to send a 1 min. And 11 second video from Adobe Premier Pro 5.5 two Adobe Media encoder 5.5, the process hangs in wait state in the Media Encoder. I have filed a request for help on the Media Encoder forum.
    I know you will put your new computer to use in helping other people and for this I thank you.

  • How can I remove the blocked contacts from skype h...

    Peace be upon you
    How can I remove the blocked contacts from skype home and all skype features?

    I found this solution and it worked.
    Paul B. Adams
    Re: safari 6.0 flash problem (blocked plug in) 
    Jul 26, 2012 7:39 AM (in response to defconnect5)
    I have a new MacBook Pro and I followed these instructions, downlonading and installing the new Flash plugin. But when I looked in "/Library/Internet Plugins" there was no folder called "Disabled Plugins".
    However, I did see two versions of Flash:
    _Flash Player.plugin with old date
    Flash Player.plugin with todays date
    I deleted _Flash Player.plugin and this fixed the problem.

  • How can i remove the shuffle feature from my nano?

    How can I remove the shuffle feature from my nano?  I apparently "shook" it and now it is on shuffle.  I can go to settings and remove the shake feature but I can't seem to restore my playing options to a generic loop instead of the shuffle.  Help!

    chelseafromco:  I had the same problem and had an awful time before finding a clear explanation of the solution.  Forget the iPod nano 6Gen manual, p. 21; it doesn't tell you how to turn the feature off, just how to turn it on.  Not all of us like randomizing our playlists.  APPLE:  PUT UP AN ARTICLE EXPLAINING SIMPLY HOW TO DO THIS.  Meanwhile, here's what worked for me:
    1.  Go to the "Now Playing" icon and tap the "Play" arrow in the center.
    2.  On the touch screen that comes up (you'll see an eighth-note graphic with the song title superimposed at the top, a Play/Pause button in the middle, and "Reverse" and "Forward" buttons on either side of that), swipe your finger to the left (not to the right).
    3.  This touch screen will have a "Repeat" symbol with two arrows like a snake eating its tail on the left and another symbol on the right that shows two arrows pointing to the right.  This is the "Shuffle" symbol.  Touch the Shuffle symbol so it's white, not blue.  White means that Shuffle is  off.
    4.  To make sure you won't accidentally turn Shuffle on, which you can do by giving the iPod a shake, go to the main Settings icon, cick it and select "Music," then press "Shake to Shuffle" until the button next to it says "Off" (white, not blue).
    Hope this helps.  By the way, in case you were wondering:  The whirling-molecule symbol in the center of the "Now Playing" controls is the Apple "Genius" symbol. This is to remind us that Apple's  manuals are created by people who don't know that customers need  instructions on how to turn things off as well as how to turn them on.

  • How can i pass the value one from to another form?

    hi all
    how can i pass the value one from to another form  with out use it when ever i want to needed this value that ican useit?
    like i have two fields U_test1 and U_test2  table name @AUSR
    that i have  four form  A! , A2,A3,A4    please tell me in details....?

    Hi,
    U can assign the values to some variables and access then in ur required forms.
    Vasu Natari.

  • How can I extract a still picture from footage in iMovie, add text to it and print it ?

    How can I extract a still picture from footage in imovie, add text to it and print it ?

    Assuming you have iMovie 11 (also known as Version 9.0.4), here is how you do it. (If you have a different version, let me know. The instructions will be different).
    First, get an app called MPEG Streamclip, which is free. (google MPEG Streamclip from Squared 5)
    Open MPEG Streamclip.
    In iMovie, select the clip you need. Then, right-click/Reveal in Finder.
    Drag this clip into MPEG Streamclip
    In MPEG Streamclip, move the playhead to the frame you want.
    In MPEG Streamclip, click FILE/EXPORT FRAME.
    Choose JPEG, TIFF, or PNG and give it a name.
    You can then use this photo in Photoshop, Pixelmator, Acorn, or the app of your choice to add text.
    Here is a demo I made the other day for how to extract the still image using MPEG Streamclip.

  • How can I extract the native SQL generated by TopLink?

    How can I extract the native SQL generated by TopLink?
    This is useful for example to use pagination, or pass the SQL to a stored procedure that may do many things, like using a cursor, or apply security.
    Pagination example where the SQL inside the inner parentheses are generated from Toplink, and the outer SQL is generic:
    select *
    from
    (select xx.*, rownum as rn
    from
    (select o.order_id, r.name, ...
    from placed_order o, restaurant r
    where o.restaurant_id = r.restaurant_id
    order by o.order_ext_id
    ) xx
    where rownum < 21)
    where rn > 10

    Alternatively, you can open your sessions.xml in the Mapping Workbench and for a specific session, you can Click the Login Tab and then the Options tab. Then select "Native SQL" and it will be outputted to the console (assuming that is where you outputing it).
    zb

Maybe you are looking for

  • Branch office PSTN call routing

    Customer had HQ and Branch office with 512 MPLS line, in HQ alone they had E1 trunk, in branch office for calling PSTN the call should travel via MPLS to HQ, and the branch PSTN call terminated in HQ only,   is it a good design or better we need to a

  • PDF form with XML data connection comes up blank at run time

    Hello All, I am a newbie to ADOBE Livecycle 9, but am very proficient in C#.  I would like to request for your guidance on the following issue. We have a desktop application in C#, WPF, Sqlserver. The requirement is to launch a Livecycle form from th

  • Can't publish iWeb due to .png error

    can't publish iWeb due to .png error

  • Itunes keeps shuffling the songs out of order when i burn a CD

    I have no idea why this is happening. The shuffle is turned off. I just installed the new version with the same results. Thanks in advance for any help.

  • Select into file with PRO*C

    Hi, i use ANSI C and ORACLE 10g. I wanna write a table into a file with PRO*C. The way I know is: exec sql; select col1, col2 into :var1, :var2 from tab; end exec; Than i open a file an write var after var into a file. i think u laugh now :-) but ple