• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

small audio program help for uni

Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#1
for my uni course i have to do a portfolio of different tasks. One is so make a short program that will play a sine wave at a frequency the user has entered then play two others an octave higher and lower. Now the first frequency and time is given to us. They are 1000.0 for frequency and 1000 for time (milliseconds) now my question is how much do i raise and lower the time for to raise and lower the frequency by an octave?
hope that makes sense thanks
 
Joined
Aug 10, 2007
Messages
4,064 (1.06/day)
Likes
1,130
Location
Geneva, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
#2
Isn't it just asking you to playing a frequency for a given time, then play it an octave higher (freq * 2) and then one lower (freq / 2 ), each for the same amount of time?
 
Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#3
Isn't it just asking you to playing a frequency for a given time, then play it an octave higher (freq * 2) and then one lower (freq / 2 ), each for the same amount of time?
no, with sine waves (or usualy refered to as sound waves) and strentching or shrinking a wave form to fit the same sine wave in a shorter space of time will either raise its pitch or lower it depending on if you speed up or slow the speed acordingly. I just do not no by how much.

edit:
this is the exact question.
Adapt the program above to play three sine waves. The user should enter a frequency and the program will play the frequency the user entered and sine waves an octave above and below the users frequency. You should do this by changing the milliseconds variable.
 
Joined
Aug 10, 2007
Messages
4,064 (1.06/day)
Likes
1,130
Location
Geneva, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
#4
I believe my way is easier ;)

But since they ask you to do it by changing the duration, to raise an octave you'd need to play the same clip in half the time, as you'd have double the cycles in a given amount of time (effectively doubling the frequency). At least that's my thinking on it... has been 10 years since Multimedia Audio 101 and 11 years since highschool band...
 
Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#5
I believe my way is easier ;)

But since they ask you to do it by changing the duration, to raise an octave you'd need to play the same clip in half the time, as you'd have double the cycles in a given amount of time (effectively doubling the frequency). At least that's my thinking on it... has been 10 years since Multimedia Audio 101 and 11 years since highschool band...
aye your way would be easier but hey if i can do it both ways i have a choice i gues:D i think your right i understand the science so to speak behind why it works, having the same amount of peakes of a wave in a shorter time space moves them closer together raising the frequency, and vise versa to lower it, but i just dont no by how much
 
Last edited:
Joined
May 27, 2008
Messages
3,577 (1.01/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#7
Can you post the code for the original program? I'd like to see it.

Thanks :toast:
shure thing give me a sec

#include"../audio.h"
#include <iostream>
using namespace std;

int main()
{
// create variables
float frequency;
int milliseconds;

//assign values
milliseconds = 1000;

cout << " enter a frequency" << endl;
cin >> frequency;
return 0;
}
i stopped on it there didnt see the point as i dont no by how much the time needs to changed so moved onto the next question
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (3.45/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
#8
If what you teacher wants is a change in freq. based upon a change in time, then the time (milliseconds) is an indicator of the period of the wave (not the duration).

You calculation is ... frequency = 1 / period.

Calculating the period (T) by frequencey is T = 1 / freq.
So T = 1 / (1000 Hz) = .001s (1 millisecond)
at 500HZ T = .002s (2 milliseconds)

I'm still have no idea what the original 1000Hz at 1000ms means, unless the time is the duration, not the periodl.
 
Joined
Jan 1, 2008
Messages
1,197 (0.33/day)
Likes
277
Location
Johannesburg, South Africa
System Name Blackbox
Processor Intel i5 750 @ stock for now
Motherboard EVGA P55 LE
Cooling Corsair H50 with 2 x Zalman ZM-F3 push/pull
Memory 2 x 2g team extreem DDR3 2000
Video Card(s) Asus GTX 460 Top
Storage Seagate 500.12, Seagate 320.11
Display(s) BenQ FP222W - 22 inches
Case CM 590 with 5x various fans (Thermalright/Noctua)
Audio Device(s) Onboard
Power Supply Corsair HX620
Software XP home SP3
#9
Can't help you with the code, but simply speaking if it goes up and octave, then it doubles in frequency. So 1kHz taken up an octave would be 2kHz.
Up an octave, double the frequency. Down an octave, half the frequency.

And if this helps, the old way of writing it was cycles per second. So 1kHz is 1000 cylces per second.

EDIT: yes, I saying the same thing as Jizzler, but just thought I'd rephrase.