File:Harmonic additive synthesis.ogg

Harmonic_additive_synthesis.ogg (Ogg Vorbis sound file, length 10 s, 155 kbps, file size: 189 KB)

Summary

Description
English: A sound created by harmonic additive synthesis. Generated by the following C++ source code (compiled with GNU g++ version 4.5.2 with libsndfile 1.0.23.)
#include <sndfile.h>
#include <cmath>
#include <algorithm>
using namespace std;
const double twopi=8*atan(1);
double Amplitude(int k, double t)
{
double mint=max(4-t,0.0)*max(4-t,0.0);
double sweepamount=0.5*(tanh(t-5)+1);
double amp=0.19*exp(-(mint*0.15+0.1)*(k-1));
amp*=sweepamount*sin(0.25*k-2*t)*sin(0.25*k-2*t)+(1-sweepamount);
if (!(k%2)) amp*=0.5*(tanh(7-t)+1);
return amp;
}
int main()
{
double sr=44100;
int nFrames=int(sr)*10;
double *buf = new double[nFrames];
double t=0, dt=1.0/sr;
double f0=440.0;
int K=44;
for (int n=0; n<nFrames; n++)
{
buf[n]=0;
for (int k=1; k<K; k++) buf[n]+=Amplitude(k,t)*sin(t*twopi*f0*k);
t+=dt;
}
SF_INFO sfinfo;
sfinfo.samplerate=sr;
sfinfo.channels=1;
sfinfo.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
SNDFILE *out = sf_open("out.wav", SFM_WRITE, &sfinfo);
sf_writef_double(out, buf, nFrames);
sf_close(out);
delete [] buf;
return 0;
}
Date
Source Own work (Original text: Self-made)
Author Chrisjohnson (talk)
Permission
(Reusing this file)
Creative Commons Attribution-ShareAlike

Licensing

Chrisjohnson at English Wikipedia, the copyright holder of this work, hereby publishes it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Original upload log

Transferred from en.wikipedia to Commons by FSII using CommonsHelper.

The original description page was here. All following user names refer to en.wikipedia.
  • 2012-01-14 23:32 Chrisjohnson 0×0× (193179 bytes) {{Information |Description = A sound created by harmonic additive synthesis |Source = Self-made |Date = 2012-01-14 |Author = ~~~ |Permission = Creative Commons Attribution-ShareAlike }}

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

14 January 2012

application/ogg

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current11:48, 9 February 201210 s (189 KB)Upload Bot (Rich Smith) {{BotMoveToCommons|en.wikipedia|year={{subst:CURRENTYEAR}}|month={{subst:CURRENTMONTHNAME}}|day={{subst:CURRENTDAY}}}} {{Information |Description={{en|A sound created by harmonic additive synthesis. Generated by the following C++ source code (compiled wi

The following 2 pages use this file:

Global file usage

The following other wikis use this file:

Metadata