Add variuos amplitudes to sound graph

Hi
I have the following code that computes a sound graph with a fixed amplitude for a number of waves. I need to be able to control the amplitude of each wave, but am not sure how to amend the following code to produce the effect. There is also an fft function that converts the amplitude time graph to frequency time graph, but I am not concerned for this now - only want to change the amplitude for n number of waves.
import java.awt.*;
import java.awt.event.*;
public class FFTv1 extends Frame
   implements ActionListener, WindowListener
  final int maxDim = 1024;
  int width =400, height =300;
  Button b;
  Complex x[];
  drawPanel pdraw;
  //float sam[] = {5, 10, 1};
  public FFTv1() {
// The title of the frame is "FFT".       
     super("FFT");
// Use the BorderLayoutlayout manager.    
     setLayout(new BorderLayout());
     addWindowListener(this);
// Instantiate a button with label "FFT" which when pressed takes the FT.
     b = new Button("FFT");
// Instantiate a panel object p where the button will be placed.    
     Panel p = new Panel();
// Place the panel p in the South position  of the frame.  
     add("South", p);
// Add the button to the panel p    
     p.add(b);
// The button listens for click events.    
     b.addActionListener(this);
// Instantiate an array x of type Complex with a length of maxDim.
// Loop over all the elements of the array setting them equal to the value of a test function
     x = new Complex[maxDim];
// Initialise the value of test function to zero for all sampling points x[i] = (0,0) for i = 0 to N-1.     
     for (int i=0; i < maxDim; i++) {
        x=new Complex(0.0f, 0.0f);
// The outer loop is over the N sample points.
// The inner loop is over the n number of graphs - in this case 2
// CAN AMPLITUDE BE ADDED BELOW??
     for (int i=0; i < maxDim; i++) {      
          for (int j=10; j < 30; j+=10) {               
     float arg = (float)(j*i * Math.PI/maxDim);
     x[i].setReal(x[i].getReal()+(float)Math.cos(arg));      
// Instantiate a panel object pdraw where the graph will be drawn.
pdraw = new drawPanel(x);
// Place the panel pdraw in the Center position of the frame.
add("Center", pdraw);
setBounds(100,100, width, height);
setVisible(true);
public void actionPerformed(ActionEvent e) {
// On clicking the button perform the FT on function contained in complex array x.
//Instantiate object fft of type FFT passing the array x to the constructor.
FFT fft = new FFT(x);
// The FT input data x is overwritten.
fft.Execute();
// The drawing panel pdraw needs to be repainted.
pdraw.repaint();
static public void main(String argv[]) {
// Instantiate an object of type FFTv1 which contains the GUI elements and thus drives the overall program.      
new FFTv1();
public void windowClosing(WindowEvent wEvt)
System.exit(0); //exit on System exit box clicked
public void windowClosed(WindowEvent wEvt){}
public void windowOpened(WindowEvent wEvt){}
public void windowIconified(WindowEvent wEvt){}
public void windowDeiconified(WindowEvent wEvt){}
public void windowActivated(WindowEvent wEvt){}
public void windowDeactivated(WindowEvent wEvt){}
To draw the graphs, we need drawPanel class
import java.awt.*;
class drawPanel extends Panel
   Complex x[];
   float ymin, ymax;
   float hscale, vscale;
   int ytop, ybot;
   float ampmax[] = {5, 10, 1};
   float ampmin[] = {-5, -10, -1};
   protected drawPanel(Complex xa[])
    x = xa;
    ymin = -1e9F;
    ymax = 1e9F;     
  public void paint(Graphics g)
      ymin = 1e9F;
      ymax = -1e9F;
       for (int i=0; i< x.length; i++)
          if (x.getReal() > ymax) {ymax = -2;}
     if (x[i].getReal() < ymin) {ymin = 2;}     
Dimension d = getSize();
hscale = (float)d.width/x.length;
vscale = 0.9f*((float)(d.height))/(ymax - ymin);
ytop = (int)(d.height*0.95);
ybot = 0;// (int)(d.height*0.05);
int x0 = calcx(0);
int y0 = calcy(x[0].getReal());
System.out.println(y0);
for (int i = 0; i < x.length; i++)
     int x1 = calcx(i);
     int y1 = calcy(x[i].getReal());
     g.drawLine(x0, y0, x1, y1);
     x0 = x1;
     y0 = y1;
private int calcx(int i)
return (int) (i*hscale);
private int calcy(float y)
     return ytop-(int)((y - ymin)*vscale)+ybot;     
//=============================================
I am hoping someone can help, as I have spent hours trying to change the amplitude - I thought it may be ymax and ymin of drawPanel - but then I cannt get n number of waves at the required frequency.
Please help!
Thanks
sam

Like this
By the way, that Abort VI button is not for stopping your loops.  I just kills execution wherever it may be.  It should only be used as a last resort if your stopping code is not working properly.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Record_BD.png ‏88 KB

Similar Messages

  • How to create a amplitude against freq graph?

    Hi, Iam new in labview. I measured amplitude from my DMM connected through GPIB. I also measured is freq result. How can i plot a graph of amplitude against freq plot?(something like a freq response plot). I do not know how to change the the x-axis of the waveform provided in labview into freq. Thank You.

    > Hi, Iam new in labview. I measured amplitude from my DMM connected
    > through GPIB. I also measured is freq result. How can i plot a graph
    > of amplitude against freq plot?(something like a freq response plot).
    > I do not know how to change the the x-axis of the waveform provided in
    > labview into freq. Thank You.
    If you are plotting an array of amplitudes sampled at various
    frequencies to a waveform graph, you are pretty close. The scale will
    default to being labeled by index -- first amplitude plotted against
    zero, second against one, etc. You can programmatically or
    interactively add a linear transform from index to displayed number. In
    otherwords, you define an M and B to define what zero maps to, what one
    maps to, etc. And you can also use t
    he labeling tool to change the
    scale label to read frequency or whatever you like.
    If your frequencies aren't in a linear progression, or if you just think
    it is simpler, use an XY graph instead, and put the frequency with each
    amplitude in a cluster. Make an array of these XY paired clusters.
    Then change the scale label.
    Greg McKaskle

  • How can I add axis to an XY-graph programmatically (in LV 6i)?

    I am currently using LabVIEW 6i to make a flexible graph window, which can be called and controlled from another VI. It's easy to send commands to the graph window over a queue interface (enabling things like adding and removing plots, changing the names, etc.)
    However, I would also like to add/remove/assign axis like this (i.e. when the program is running). It seems to me that there isn't an attribute or method available on the XY-graph that will allow this.
    My best solution so far is to have a maximum number of axis present, and then hide/show them when axis are removed/created. However, this triggers a bug in LV (AFAIK) when the axis are shown/hidden out of order (they will be shown
    on top of each other). Now this can be solved by setting the positions/sizes of all axis every time, but that seems like a lot of work...
    Is there a way to add/remove axis to an XY-graph programmatically (in LabVIEW 6i)?

    I have not found a way to programmatically create/remove scales in LabVIEW.
    In regards to the error, I would suggest updating to LabVIEW 6.0.2. I wrote a simple VI that tested this funcitonality and did not have any problems. The link to the 6.0.2 update is:
    http://digital.ni.com/softlib.nsf/websearch/F983BDA17B8F401B862569EC005A11C2
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • How can i mark user defined points in amplitude versus frequency graph?

    i have an array of frequencies and amplitudes . i need these values to be displayed on x-axis frequency values and y axis amplitude values . one fixed default plot should be continuously visible in this graph and then i wish to mark few user defined points in the same graph, save these two plots in the same graph and then take a print out of the graph.
    Kindly help this is regarding my master of engineering project where i am trying to biuld an audiometer (for testing hearing sensitivity) and i am going to interface labview with ardiuno micrcontroller and my hardware devices.
    so kindly help.
    thank you.
    vanashree
    Solved!
    Go to Solution.

    hey....m able to generate a multiplot...
    it works...
    i have placed two fixed plots on it...
    now just one thing remains..i need to place user defined points on the same plot...i have attached my work..i have labview 7.1
    Attachments:
    24th home try me.vi ‏157 KB

  • Add axis label to a graph in word report

    Hi,
        Is there a way to add an axis label for the graph in a word report? Thanks!
       Tom
    Solved!
    Go to Solution.

    I would guess that there is, but it would be a word automation function.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • I can't add a custom alert sound.

    I'm trying to add a custom sound for when a buddy logs in. The problem is, after I go through the add sound steps, the sound never shows up in the list and the event alert goes back to its default alert. I'm using iChat AV 3.0.1 (v392), and using AIM.

    Hi Robert,
    Welcome to the Apple Discussion Pages.
    The sounds need to be of the right quality (too high does not work).
    They also need to be in the right folder. Sounds can be put in your Home folder/Library/Sounds and will appear in the third division of the sounds available to iChat. They are iChat's Own sounds, the System Sounds and any in your Home/Library/Sounds folder, separated by feint lines in the drop down.
    Ralph

  • Add A Constant Background Sound.

    I'm a bit of an amature when it comes to web design and especially hard coding.Im getting to grips with div tags and the css dialoge box. I able to embed a sound file on a page but would like to know how to embed a  background sound which keeps playing and doesnt restart every time you select a new page. Also any advice on how to add a sound on/off button option on each page would be appriciated.
    Thanks

    Continuously playing music/sound on HTML websites is not a simple thing to do.  You have the following options, each with their own set of problems.
    OPTION #1 - Embed an MP3 player on a plain vanilla page. Invoke it to open in a Pop-Up window from a link on your home page.   The player will remain open while people explore other site pages or until they close the pop-up window or leave your site.  NOTE:  The user must initiate the pop-up page by clicking a link. If you attempt to open the pop-up automatically on page load, it will be defeated by pop-up blockers (98% of browsers).
    OPTION #2 - Put your player into a frameset.  NOTE: Framed sites pose many other problems as detailed below.
    http://apptools.com/rants/framesevil.php
    OPTION #3 - Build your entire site with Flash.  NOTE: Flash sites are not SEO & user friendly. Also Flash isn't supported by all web devices.
    OPTION #4 - Build your entire site on one very large page
    EXAMPLE:  http://alt-web.com/TEST/ScrollTo.shtml
    Depending on content, this could delay page load quite a bit.
    OPTION #5 - Forget about continuous music/sound.  Simply embed a player on the first page and let people hear it once.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • How can I add transition or effect sound?

    Hi,
    I know how to make a sound effect on a slide, but it is for the whole slide.
    How can I add a transition or effect sould only during the transition period when I click my mouse?
    Powerpoint can do it easily, can you send the answer to my email please?
    Like (0 

    just think about the voice setting when you go to the record you should find mono and stereo. I have only mic volume -cd volume and line volume i should have mono mixer and stereo mixer also.
    So can i add them to the list ?? For example when you use paltalk program you can play music from your computer in the room so all in this room can hear it eaven if you adjust your volume to mute,this is using mixer mono or stereo.
    I hope i explane it for you. Thanx

  • Add plots to digital waveform graph programmatically

    Hi Guys,
                This might be an easy one but I can't seem to find the right property. I'm adding "Plot Name" values for a each Plot in a Digital Waveform Graph. I select each plot with "Active Plot" property and name it. However if there are already e.g. 7 plots and I try to set eight plot active (i.e. 7 = Active Plot) I get an error cause this eight plot doesn't exist on the graph, and so can't be named.
        How can I add (or indeed remove) plots using property nodes?
        Thanks

    Hello,
    One thing to consider is the actual data the graph is receiving.  Choosing plot 8 in this case is perhaps attempting to choose a plot which doesn't exist in the data, which could be why you're seeing the error.
    Off the cuff, one thought might be to have the following "steps" take place when you want to add plots:
    on the appropriate action to create a plot, create a default data set representing that plot
    package that with your overall graph data so that the new plot exists in the data
    write that data to the graph, perhaps using the Value Signaling property (via a property node linked to the Graph)
    trap the graph's Value Change event using an event structure (possibly in a parallel loop) and update the plot name there (much like you are today - using a property node to first set the active plot to <previous value + 1> since you just added a plot, and then set your new plot name)
    Not sure what the rest of your application looks like, but hope this helps!
    Best,
    JLS
    Sixclear

  • How to add audio devices under sound in system preferences

    How do I add output audio devices under system preferences --only option listed is internal speakers?
    Macbook help says to change device under sound in system preferences. However, only option listed it the internal
    speaker.
    I need to sound to come from my tv which is hooked via vga cable and audio cable.
    Every thing works but I cannot get sound from tv.

    You are my hero. I'm not very savy when it comes to connections. I had the audio cable hooked up to the audio port which is next to the headphone port on my macbook. After switching the tv was listed just as you said it would. Thanks so much. I'm now a very happy camper.

  • How to Add the title name for Graph in Excel

    Dear Friends
                      I am using LabVIEW 8.0.I need how to add the title name for chart in Excel.
    Jayavel
    Solved!
    Go to Solution.

    Do you have the Report Generation Toolkit? If so, the Excel Easy Graph VI has an input for that.
    If you don't have the toolkit then you will need to use ActiveX. Please do a search on how to use ActiveX (there are examples that ship with LabVIEW) to control Excel. There are also lots of example in the Excel thread. NOTE: DO NOT POST QUESTIONS IN THAT THREAD. 
    Ultimately you will need to look up the information in MSDN. 

  • Crystal Report - How to add a baseline in the graph?

    Is there any function available to add a baseline in a line chart?
    Thank You!

    The standard answer would probably be to create an additional series of data for your graph and then plot that series as a line (CR allows combo bar/line/area charts).
    If all else fails, this is easily doable with our CRChart add-in, which has extensive support for user-defined lines: Up to 20 different lines, values set at runtime, show values and/or arbitrary labels on the lines.  But... this solution costs money
    -Dan
    disclaimer: I work for the company, threedgraphics.com, that makes this product.

  • Why can't I add final cut pro sound effects?

    I am wanting to add a sound effect or background music to my video but I can't access it through final cut pro x.  I see the only option I can add music through is iTunes.  It doesn't give me any other folders.  I even tried to drag in the folders from the finder (because these sound are in my computer) but that didn't seem to work. Please help!

    Skyking wrote:
    I'm wondering if that had something to do with it.
    I doubt it.
    Howvever, in hte category of misery (actially, an annoyance) loves company, I have a similar photo browser issue. It links…until it doesn't.
    Russ

  • Is there a way to change or add to the system sounds on my iPod touch 4g?

    I was looking for a way to add or change the system sounds that are on my iPod.  I use it with iTunes on my WinXP laptop, if that matters at all. 
    Thanks!

    The sounds that are available for things like email, calendar, etc.  I was hoping to add to the default selection of sounds that come standard on the device.

  • Why is it that an amplitude-scaled sound does not play louder than the original sound using Play Waveform?

    I don't know if I have posted this on a correct location (kinda new here).
    I am trying to demonstrate the effect of multiplying a constant to a waveform. I have a sound file read by Sound File Read Simple.vi. Then I am trying to scale the amplitude of the signal by a constant number. I've tried three methods for this: the Numeric Multiplication, the express VI Scaling and Mapping, and the scaling and conversion VI of Signal Express. The waveform shows that the amplitude of the scaled signal is indeed scaled, but when played thru the play waveform VI, the sound level is still the same, no matter how much I am scaling the input. Does anyone why is this so? Also, I really wanted to show that scaling an audio waveform results in a louder waveform. How do I do this? As much as possible, I've wanted to use simple VIs as the class is an introduction to signal processing and the students (and so am I) are still finding our way into LabVIEW (we used to use MATLAB in the course).
    Attachments:
    scaling.vi ‏69 KB

    JaymeW wrote:
    Hi kirkbardini,
    According to this article about Low Volume From Sound VI, you can use a scalar multiple to increase the volume of a sound saved to a .wav file, so you should be able to do this before playing it.  Does that not work for you?
    That information is for Labview 7.x and hence outdated. As mentioned before. Labview do a normalization before sending data to the sound card. As you know sound cards are most often 16 or 24 bits. And in most cases data input to a sound card is in DBL type. After normalization the data is converted so the floating point value 1 represent full scale output on data sent to the the sound card DA. To get any further I suggest kirkbardini take the time needed to send us his/hers current code. Then we may solve things from there
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

Maybe you are looking for

  • Advice on best office grade A3 graphics colour printer/copier

    Currently we lease a Canon iR2200 (which is black & white) via IKON in the UK: http://www.canon-europe.com/ForWork/Products/Office_Print_Copy_Solutions/Digital_IRSeries/iR2200/index.asp?ComponentID=25508&SourcePageID=26027 http://www.uk.ikon.com/ But

  • How to get the total record count in ODI

    Hi I have the interface the are file to DB. The format is like this.. HEADER DETAIL TRAILER Now will write the contains of file to DB, But i have to insert the total count ie numberof record written from file to DB in my Trailer record. can you tell

  • 2 Users - Shared Music - additions not registering

    We're on an iMac with two users, myself and my wife. Both of our iTunes are set up to share music with each other. I just downloaded a new CD to my library, but it's not showing up in her library. any ideas?

  • Implementing comparable for a TreeMap

    I'm trying to create a League of Players which is ordered by the player grade, but the comparism method (compareTo) doesn't seem to be getting called. The following list should be displayed in grade order RANK LIST 950 Alactaga 1000 Aragorn 1000 Blac

  • ABAP to Netweaver

    hi friends,      currently i am working as ABAPER and having 1.8 yrs of experience and i am working on support (maintaince) Project and i want to move towards development in software company .Can any body suggest me where should i get the ebooks/ stu