Display sound data value from ByteArrayOutputStream

hi People,
Can advise what is the function that i can use to retrieve or display the data that i stored in ByteArrayoutputStream buffer?
So far i can only store the data in... but how can i retrieve and display them on output panel?
Many Thanks

Hi again,
I have modify my code and found the error.. But this time i can't display the value correctly. Please advise...
//This method captures audio input from a microphone and saves it in a ByteArrayOutputStream object.
private void captureAudio(){
try{
//Get and display a list of available mixers.
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
System.out.println("Available mixers:");
for(int cnt = 0; cnt < mixerInfo.length; cnt++){
System.out.println(mixerInfo[cnt].getName());
}//end for loop
//Get everything set up for capture
audioFormat = getAudioFormat();
DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class,audioFormat);
//Select one of the available mixers.
Mixer mixer = AudioSystem.getMixer(mixerInfo[3]);
//Get a TargetDataLine on the selected mixer.
targetDataLine = (TargetDataLine)mixer.getLine(dataLineInfo);
//Prepare the line for use.
targetDataLine.open(audioFormat);
targetDataLine.start();
//Create a thread to capture the microphone
// data and start it running. It will run
// until the Stop button is clicked.
Thread captureThread = new CaptureThread();
captureThread.start();
} catch (Exception e) {
System.out.println(e);
System.exit(0);
}//end catch
}//end captureAudio method
public int[] ConvertSoundData (byte[] SoundData, int SampleTotal){
//Determine the original Endian encoding format
boolean isBigEndian = audioFormat.isBigEndian();
//this array is the value of the signal at time i*h
int x[] = new int[SampleTotal];
int value;
//convert each pair of byte values from the byte array to an Endian value
for (int i = 0; i < SampleTotal*2; i+=2) {
int b1 = SoundData;
     int b2 = SoundData[i + 1];
     if (b1 < 0) b1 += 0x100;
     if (b2 < 0) b2 += 0x100;
     //Store the data based on the original Endian encoding format
     if (!isBigEndian) value = (b1 << 8) + b2;
     else value = b1 + (b2 << 8);
     x[i/2] = value;
return x;
//This method creates and returns an
// AudioFormat object for a given set of format
// parameters. If these parameters don't work
// well for you, try some of the other
// allowable parameter values, which are shown
// in comments following the declartions.
private AudioFormat getAudioFormat(){
float sampleRate = 8000.0F;
//8000,11025,16000,22050,44100
int sampleSizeInBits = 16;
//8,16
int channels = 1;
//1,2
boolean signed = true;
//true,false
boolean bigEndian = false;
//true,false
return new AudioFormat(
sampleRate,
sampleSizeInBits,
channels,
signed,
bigEndian);
}//end getAudioFormat
//=============================================//
//Inner class to capture data from microphone
class CaptureThread extends Thread{
//An arbitrary-size temporary holding buffer
byte tempBuffer[] = new byte[10000];
public void run(){
byteArrayOutputStream = new ByteArrayOutputStream();
stopCapture = false;
try{//Loop until stopCapture is set by another thread that services the Stop button.
while(!stopCapture){
//Read data from the internal buffer of the data line.
//targetDataLine.read(byte[] b, int off, int len)
int cnt = targetDataLine.read(tempBuffer, 0, tempBuffer.length);
if(cnt > 0){
float sample_rate = audioFormat.getSampleRate();
float T = audioFormat.getFrameSize() / audioFormat.getFrameRate();
int n = (int) (sample_rate * T ) / 2;
System.out.println(n); ---------> to print the number of sample
//Save data in output stream object.
byteArrayOutputStream.write(tempBuffer, 0, cnt);
int[] SoundData = ConvertSoundData(tempBuffer,n);
for(int index = 0; index < SoundData.length; index++){
System.out.println(index + " " + SoundData[index]); ----------> to print the ALL sound data in the returned array.
}//end if
}//end while
byteArrayOutputStream.close();
}catch (Exception e) {
System.out.println(e);
System.exit(0);
}//end catch
}//end run
}//end inner class CaptureThread
The result i got during i sing "hmmm" to my microphone is as below:
1
0 1281
1
0 61184
1
0 24830
1
0 25598
1
0 33279
1
0 25350
1
0 19728
1
0 54537
Below is my question:
1) Why the number of sample keep on remained as 1? Since the sampling frequency is 8000Hz..
2) Why my index variable remained as 0? I suppose i will have 8000 values since my sampling rate is 8000Hz... Is it impossible to print 8000 data within 1 sec?
Is it advisable if i transfer the obtained numeric array directly for FFT analysis?
(I wish to do a real time frequency analyzer. With MATLAB, I can only do an analyzer by retrieving the .wav data content.)
I am shame to say i am still not clear enough with the sampling and data retrieve algorithm. Thats why i will have difficulties to delliver correct idea.
Appreciate if you have any tutorial can share with me so that i can understand more.
Thank you again.

Similar Messages

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • How to change a date value from "java.util.Date" to "java.sql.Date"?

    Hi all,
    How to change a date value from "java.util.Date" to "java.sql.Date"?
    I m still confusing what's the difference between them.....
    thanks
    Regards,
    Kin

    Thanks
    but my sql statement can only accept the format (yyyy-MM-dd)
    such as "select * from xx where somedate = '2004-12-31'
    but when i show it to screen, i want to show it as dd-MM-yyyy
    I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
         public String date2str(java.util.Date thisdate)     {
              if (thisdate != null)     {
                   java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
                   return date2str(thissDate);
              }     else     {
                   return "";
         public String date2str(java.sql.Date thisdate)     {
              if (thisdate != null)     {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   return sdf.format(thisdate);
              }     else     {
                   return "";
         public java.util.Date str2date(String thisdate)     {
              String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
              java.util.Date returndate = null;
              if (thisdate != null)     {
                   SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
                   try {
                        returndate = dateFormatter.parse(thisdate);
                   } catch (ParseException pe) {
                        System.out.println (pe.getMessage());
              return returndate;
         }

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • Not to display the null values from data base

    Hiiii.
    In a jsp file i have ten check boxes.The jsp file is mapped to a servlet file for parameter requesting and to
    store it in DB.
    The unchecked box values has null values.All the values are store in a Mysql DB table.
    Again i have to display it in a jsp page from table.
    The problem am facing was,how can i display only the values in a row.it must not display the null values and the crresponding column name.
    Or any other way is their like below
    How i can retrieve only the selected check boxes from tht jsp file.and store in backend.
    Thanks in Advance
    regards,
    satheesh kannan

    Here is a rough example that may give you some ideas:
    On the JSP page:
    <%if(myData.getFirstName()!=null){%>
    Your First Name'
    <input type="text" name="firstName" value="<%=myData.getFirstName()%>">
    <%}%>
    In the servlet:
    String firstName= request.getParameter("firstName");
    if(firstName!=null){
    //write it to the database
    }

  • How to get shared date value from subreport to main report

    Hi,
    I need your help in passing the value of a running total that is located in the subreport to the main report. The running total in the subreport is getting the maximum of the Effective Date (which it is type in the database is date) for each group and it is value will change on the change of the sequence no. group. I am printing the value at the group footer which displayed correctly. Now my issue is that how to pass the value from the subreport to the main report as a date. I have created a formula that it is having the code:
    shared datevar ddd := date(0,0,0);
    ddd:={RTotl0}
    The above formula is not compiled and it is first giving me an error at line 1 that date(0,0,0) is not accepted. Then when I removed it, it gave me an error that ddd:= can't have a running total to a datevar.
    So can you please help in getting the value from the subreport and then to pass it to the main report as a formula as I need to include it in other formulas which it compares the dates.
    Thanks

    Hi Mohammed,
    Are you displaying the shared variable on the Main Report's group footer as well?
    Try changing the code to:
    shared datevar ddd := cdate(0,0,0);
    ddd:= date({RTotl0});
    -Abhilash

  • To get date values from a varchar column

    hi,
    i got an errorin oracle reports 6i
    actually my problem is my client used dff so when we enter data from front end tht data is storing in attribute columns in backend.nw i want to build a report by using the dates as parameters. i result must be in between the dates i hv mentioned. for giving runtime parameters i must take values from attribute column. tht column is varchar.
    i tried
    to_date(nvl(columnname,'01-JAN-2000'),'DD-MON-YY')between :p_from_date and :p_to_date
    i got error non numeric is found where numeric expeted and if i change format i got invalid month
    i used trim then i didnt get error but i got wrong data
    nVL(TRIM(columnname),'01-JAN-51') BETWEEN TRIM(:P_FROM_DATE) AND TRIM(:P_TO_DATE)
    so please help me
    im new to this oracle apps also.
    thanks in advance,
    radha

    --columnname,'01-JAN-2000'),'DD-MON-YY')
    This doesn't seem to be correct your format is 01-JAN-2000, however the date format you pass is DD-MON-YY

  • ADF train task Flow display name comonent value from bundel

    hi
    i have som problem with adf bounded task flow train.
    i build a bounded task flow as fragment and train and i add display name component to each view , but how i can give the display name value from a view controller bundel .
    regards mohammad.j.yaseen

    1). Select the component for which you want to set the attribute to a bundle
    2). In the property inspector, click the context menu next to the attribute you want to pick from a bundle (the thing that looks like a "V" next to the field"
    3). Choose "Select Text Resource..." from the resulting menu

  • How to get the Date value from DB

    Hi All,
    I give one string parameter (25-Jan-07). My database table stored in some dates and values. How i'll get the all date value(25-Jan-07) and the correspong values?
    Thanks!

    SELECT *
    FROM your_table
    WHERE date_column = to_date('25-Jan-07', 'dd-Mon-yy')Why oh why oh why are you using dates with two-digits representing the year? In my opinion, this is bad and wrong. Be explicit; use 4 digits. is your "07" representing 1907? 2007? 2107?

  • Displaying a field value from PL/SQL

    I'm working on a master detail form. In the detail section, I have added a button beside one of the fields. On the click of this button, I want to use a foreign key value from the current record, and get the description field from another table. I'm able to get the value from the form by use of p_sesion.get_value_as_NUMBER. I then perform the select statement to retrieve the description from another table. I would like to display this value to the user. Any ideas as to how I can do this?

    Bala,
    Just an update to let you know what we've tried up to this point:
    We have created 3 functions:
    1) Set_Occup_Desc - this sets the Occupation Description.
    2) Get_Occup_Desc - this retrieves the Occupation Description.
    3) Clr_Occup_Desc - this clears the Occupation Description.
    On the click of the button, I have the following code:
    declare
    my_occup_desc varchar2(525);
    my_occup_key number;
    my_return_val boolean;
    begin
    my_occup_key := p_session.get_value_as_NUMBER(p_block_name => 'DETAIL_BLOCK', p_attribute_name => 'A_OCCUP_KEY', p_index => 1);
    select occup_desc into my_occup_desc from wsoccup where occup_key = my_occup_key;
    my_return_val := wsurv_util.set_occup_desc(my_occup_desc);
    end;
    In the After Displaying Form section, I have the following code:
    htp.p(wsurv_util.get_occup_desc());
    This doesn't display anything on the page, and I think that it's because multiple oracle sessions are being used within the one portal session, and the value of the variable is being lost.
    Any ideas on a work around for this one?

  • Safari Displays Unexpected Date Value

    I want to use the following script in my company website www.todoroffs.com, in order to always display the current year value within my copyright notice at the bottom of the pages:
    <script>
         var today=new Date()
         var todayy=today.getYear()
         document.write(""todayy"")
         </script>
    Safari displays the value "105" while other browsers display the desired value "2005".
    Furthermore, I want to use the following script which is a variant of the first script:
    <script>
         var today=new Date()
         var todayy=today.getYear()
         document.write(""todayy-1914"")
         </script>
    Safari displays the value "-1809" while other browsers display the desired value "91".
    Is this a bug in Safari? Is there a work-around?
    Thank you.

    Hi iBod,
    I am not familiar with getFullYear( ).
    I modified my code as follows:
    Copyright © 1997–getFullYear( )
    Safari and others display it as:
    Copyright © 1997–getFullYear( )
    What is the proper syntax and format?
    Thank you.

  • Store date value from calender

    I have created a calender on a page which shows all date's of the month with sysdate(30th june06) (current date or today's date), Now i want to store any date value of the month in the item value i.e if i click on 5th june 06 then that value should be stored in the item value. Can anybody help ?
    ramesh

    Thanks Denes Kubicek
    The example is good and i need to modify that if i select the column from the selectlist then
    1) The report should give all the columns and the same column name should be used for where clause for the search.
    2) In the example the query is
    DECLARE
    q VARCHAR2 (4000);
    BEGIN
    q := ' select ';
    q := q || REPLACE(NVL(NVL(:p1_columns, CASE WHEN :p1_multiple_select LIKE 'NUL' THEN NULL ELSE :p1_multiple_select END), 'EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO'),':',', ');
    q := q || ' from emp ';
    RETURN q;
    END;
    which gives column to selected column , but i want to get all columns so to modify the query.
    p1_columns is not required.
    Thanks,
    Ramesh.

  • Extracting the date value from digital signature/certificate

    Hello,
    I'd like to extract the date from the signature properties and copy the value over to the date field as shown in snapshot.
    I am aware that we can change the appearance of the digital signature to make the date visible but in most case, it is too small to read on hardcopies.
    We resort by manually typing in the date, zooming into PDF to read visible date (if any) associated with signature image, to click on the signature image to open the Signature Properties dialog, or to open the Signatures tab window docked to the left.
    Manual typing in the date expose us to discrepancy problem when the PDF was created vs. the actual date the PDF was signed (date value associated with digital signature/certificate). For example, person A created a PDF with date typed in and then sent that file over to person B (approving the document), who may digitally sign it a few days later.
    Hope I am making sense.
    Regards,
    Devin
    Note: I have originally posted my question in other thread at http://forums.adobe.com/message/3296355

    You can get the data and other signature properties using the  signatureInfo field method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.756.html
    But for you application you really should be setting the date field before the signature is applied, since changing it afterwards would invalidate the signature. You can execute a script that sets the valud of the data field with the current date using the "Signaute Signed" event, which you'll see as one of the tabs of the signature field properties dialog.

  • How to get Date value from database and display them in a drop down list?

    Hello.
    In my Customers table, I have a column with Date data type. I want to create a form in JSP, where visitors can filter Customers list by year and month.
    All I know is this piece of SQL that is convert the date to the dd-mm-yyyy format:
    SELECT TO_CHAR(reg_date,'dd-mm-yyyy') from CustomersAny ideas of how this filtering possible? In my effort not to sound like a newbie wanting to be spoonfed, you can provide me link to external notes and resources, I'll really appreciate it.
    Thanks,
    Rightbrainer.

    Hi
    What part is your biggest problem?? I am not experienced in getting data out of a database, but the way to get a variable amount of data to show in a drop down menu, i have just messed around with for some time and heres how i solved it... In my app, what i needed was, a initial empty drop down list, and then using input from a text-field, users could add elements to a Vector that was passed to a JComboBox. Heres how.
    package jcombobox;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    public class Main extends JApplet implements ActionListener {
        private Vector<SomeClass> list = new Vector<SomeClass>();
        private JComboBox dropDownList = new JComboBox(list);
        private JButton addButton = new JButton("add");
        private JButton remove = new JButton("remove");
        private JTextField input = new JTextField(10);
        private JPanel buttons = new JPanel();
        public Main() {
            addButton.addActionListener(this);
            remove.addActionListener(this);
            input.addActionListener(this);
            buttons.setLayout(new FlowLayout());
            buttons.add(addButton);
            buttons.add(remove);
            add(dropDownList, "North");
            add(input, "Center");
            add(buttons, "South");
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == addButton) {
                list.addElement(new SomeClass(input.getText()));
                input.setText("");
            } else if (e.getSource() == remove) {
                int selected = dropDownList.getSelectedIndex();
                dropDownList.removeItemAt(selected);
        public void init(String[] args) {
            setSize(400,300);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(new Main());
    }And that "SomeClass" is show here
    package jcombobox;
    public class SomeClass {
        private String text;
        public SomeClass(String input) {
            text = input;
        public String toString() {
            return text;
    }One of the things i struggled a lot with was to get the dropdown menu to show some usefull result. If the list just contains class references it will show the memory code that points to that class. Thats where the toString cones in handy. But it took me some time to figure that one out, a laugh here is welcome as it should have been obvious :-)
    When the app is as simple as this one, using a <String> vector would have been easier, but this is just to demonstrate how to place classes in a vector and get some usefull info out of it, hope this answered some of your question :-)
    The layout might have been easier to write, than using the toppanel created by the JApplet and then the two additional JPanels, but it was just a small app brewed together in 15 minutes. Please comments on my faults, so that i can learn of it.
    If you need any of the code specified more, please let me know. Ill be glad to,

  • Pull/Get Data/Value from User Input Window

    I'm trying to do something that should be be quite basic for a programer, but unfortunately unfortunately being a designer I'm having a heck of a time with this.  Having spent hours searching and trying different things I thought of posting the problem.  I have the feeling I'm not the first designer struggling with this.
    I'm trying to pull input data from a window and pass it on to a variable.  In the script I do a couple of purge(), and I'm not sure if that will clear the user input values during the script, but this is thinking ahead...
    I need values to do:
    layer.translate(X, Y) // If I'm not wrong this needs to be a - string
    bitsaveoptions.method = ChanelScreen; //from drop down menu
    bitsaveoptions.angle = KAngle //  If I'm not wrong this needs to be a - integer
    bitsaveoptions.frequency = ChanelFrequency; //  If I'm not wrong this needs to be a - integer
    bitsaveoptions.resolution = ChanelResolution; //  If I'm not wrong this needs to be a - integer
    bitsaveoptions.shape = BitmapHalfToneType.ROUND; //from drop down menu
    I know that there are different ways to retrieve the data from a window .selection .value and maybe others but I can't seem to pull the data out of from the user input
    Any advice would be greatly appreciated. 
    Thanks.
    PS I'm working with Photoshop CS5
    This is what I have so far.
    // =========== Ruler to Millimiters
    app.preferences.rulerUnits = Units.MM;
    var doc = app.activeDocument;
    var layer = doc.activeLayer;
    var dropdownlistArray = new Array();// The array of drop down lists.
    var chosen_action = null;
    var ScreenShapeArray= new Array(
    'Round',
    'Eliptical'
    var WinContent =
    "dialog{\
        orientation: 'column', \
        alignChildren: ['fill', 'top'],  \
        preferredSize:[300, 130], \
        text: 'Export Settings',  \
        margins:15, \
            Coordinates: Panel {\
            orientation: 'column', \
            text: 'Chanels Shifts', \
            margins:15, \
            alignChildren: 'right',\
                KChanelX: Group{\
                st: StaticText { text: 'X:' }, \
                te: EditText { text: '15', characters: 4, justify: 'right'} \
                st2: StaticText { text: 'mm' }, \
                KChanelY: Group{\
                st: StaticText { text: 'Y:' }, \
                te: EditText { text: '10', characters: 4, justify: 'right'} \
                st2: StaticText { text: 'mm' }, \
        bottomGroup: Group{\
            cancelButton: Button { text: 'Cancel', properties:{name:'cancel'}, size: [120,24], alignment:['right', 'center'] }, \
            applyButton: Button { text: 'Apply', properties:{name:'ok'}, size: [120,24], alignment:['right', 'center'] }, \
    // ======== Create window object
    var win = new Window(WinContent);
    // ======== Display Window
    win.show();
    var X =parseInt(win.Coordinates.KChanelX.te.selection);
    var Y =parseInt(win.Coordinates.KChanelY.te.selection);
    alert (X); // Here I get NaN
    alert (Y); // Here I get NaN
    if (typeof(X) === "undefined" || typeof(Y) === "undefined" ){
    layer.translate(X+"mm", "-"+Y+"mm");
    }else {
    alert ("here"); // Always end-up here regardles of canling or acepting the default values

    .text
    Is what I was looking for!
    Not being so programming savvy, and not knowing the proper terminolgy makes things way harder.
    You asked what the script is for:
    I'm creating an interface to save multiple file from a master file.
    1. Set the bitmap conversion presets (res, screen type, shape, lpi, angle), for the desired chanels to export, set the pages in the book that will be produced, number of signatures, as well as pages per signature.
    2. Create tiffs for every chanlel and move the chanel according to the presets tied to the signature the page belongs to in the book.
    3. Reassemble the chanels into one file for viewning and use the tifs for print.
    Total I will have:
    Myfile_C.tif //Cyan
    Myfile_M.tif //Magenta
    Myfile_Y.tif //Yellow
    Myfile_K.tif //Black
    Myfile_col.psd //CMY chanels reassembled
    Myfile_sep.psd //CMYK chanels reassembled
    Why am I doing all this? I'm working on a comic that will simulate a silver age comic book and I need the look of that time, with off registration plates. But I also need to see the final result of the shift and keep things constant for each plate as I'm working on the separate pages, so series of presets are a must for me.
    If the result of the interface is somewhat acceptable I'll post it.
    Thanks for the help I really apperciate it.

Maybe you are looking for

  • 10g Releae 1 move from J-Initiator to JRE

    Hello everyone, Hope you folks can help me out on this problem. We are using 10g release 1 - Version 9.0.4 It's installed on unix solaris. The end users access the application through Internet explorer 6 and J-Initiator and webutil. Currently the ope

  • Pull the data from ORACLE

    Hi Guru's, I would like to know ,How to pull the Data from Oracle tables to BW. tell me scratch onwards... regards sekhar ch

  • Incentive Compensation Enquiry

    Hello World, I am in the process of implementing Oracle Incentive Compensation for my first time, and am facing many problems in how sales targets are entered to the system for each salesperson? How actual sales and invoices collection is captured? H

  • Sub Headings in Excel Layout

    Hi, I am using key figures in Lead column,I would like to have sub heading in between the key figures, I tried in last screen of layout but its not saving. Can anyone help me out please. My requirement Revenue(key figure) Grosmargin(KF) REVENUE DRIVE

  • Implementation Methodology for EP

    Hi Experts, Is there a standard Implementation methodology / document templates for EP Implementation? Is there some Solution Manager Guidelines for a SAP EP Implementation? Regards, Shobhit