Help: Staircase Waveform file needed! - Page 1
Forum section: electronics / projects

author: truzz
author_rank: Newbie
timestamp: October 26, 2013, 09:47:02 am
content: Hi folks,I searched online: no luckProbably some of you owning an arbitrary waveform generator may help.I need a .wav mono file containing anup-going 7-step staircase wave form.Step period should be10mS.Total level 0dBFS.If anyone could help, that would be fantastic!Thanks in advance.

author: Bored@Work
author_rank: Super Contributor
timestamp: October 26, 2013, 11:45:53 am
content: LTspice can generate wav files. GNU Octave can generate wav files. Matlab can do so, too. And maybe a hundred different tools. So what exactly is the problem?

author: truzz
author_rank: Newbie
timestamp: October 26, 2013, 02:58:12 pm
content: Thanks for the quick reply.I just don't know how to do it.

author: codeboy2k
author_rank: Super Contributor
timestamp: October 26, 2013, 10:29:19 pm
content: This really sounds like homework.You even included a nice image of question (b) with the 7 step staircase and the step parameters.If this is homework, you should really go through my explanation below and learn what I've done.Bored@Work suggested some tools to use, so lets choose one: GNU Octave...Code:octave:2> help wavwrite'wavwrite' is a function from the file /usr/share/octave/3.6.4/m/audio/wavwrite.m-- Function File: wavwrite (Y, FILENAME)-- Function File: wavwrite (Y, FS, FILENAME)-- Function File: wavwrite (Y, FS, BPS, FILENAME)Write Y to the canonical RIFF/WAVE sound file FILENAME with samplerate FS and bits per sample BPS. The default sample rate is 8000Hz with 16-bits per sample. Each column of the data represents aseparate channel.See also: wavreadOK, so each column of the data represents a separate channel and you said you need mono, so that's 1 channel. Lets make a column matrix of sample data.It says the default sample rate is 8000Hz, so the period is 1/F = 1/8000 = 125us time period between samplesYou said you needed a 10ms step period, thats 10ms/125us = 80 samples for each "floor" before it steps up to the next level.So your column vector Y has to have 80 samples at the first level, then step up to the next level and 80 more samples, etc... for a total of 7 steps (which is 8 levels)Code:% get 8 evenly spaced steps between -1.0 and 1.0, gives the following steps% -1.00000 -0.71429 -0.42857 -0.14286 0.14286 0.42857 0.71429 1.00000steps = linspace(-1.0,1.0,8)Y = [];for thestep = stepsY=[Y;ones(80,1) * thestep] % build a vector with 8 steps of 80 samples eachendforwavwrite(Y, "/tmp/step.wav")That should get you started.. So, download GNU Octave, make a for loop, fill a column vector, and write it out using the wavwrite() function. GNU Octave is similar to MATLAB if you have that already. Newer versions of MATLAB use audiowrite().I loaded the wav file into Audacity. It looks like this, below. You'll see that it is 80ms in length. The vertical steps look a little crooked because they are. There is nothing wrong with the data. Think about it.. the sample n+1 is not directly above sample n, its displaced in time. You would see this less obviously with a higher sample rate.I've done lots for you already, and I think this is homework.. so download GNU Octave and learn to make it dance for you

author: truzz
author_rank: Newbie
timestamp: October 27, 2013, 08:12:23 am
content: codeboy,thanks for taking the time to reply.I'm a newbie here, just to clarify, I'm not a programmer, don't know how to use matlab, octave etc.Maybe I was unclear, I simply asked for an audio WAV file with a staircase waveform,I guess it would be very simple to record it through an AWG,or if you can program it, through the SW you mentioned.There are many online generators, they make sine, triangular, sawtooth, in16-bit 44.1kHz WAVformat,unfortunately none makes a staircase waveform to use it in my sound card.If anyone is able to record an audio WAV file, that would be great and helpful.Thanks in advance.

author: Jon86
author_rank: Frequent Contributor
timestamp: October 27, 2013, 10:23:30 pm
content: Oh come on, he took the time to write all that out for you and you're still asking to have it given to you on a plate? At least give GNU Octave a go...