<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OFでSoundプログラム &#187; エフェクト</title>
	<atom:link href="http://munetika.com/blog/category/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/feed" rel="self" type="application/rss+xml" />
	<link>http://munetika.com/blog</link>
	<description>ofxMaximを中心にサウンドプログラムを。</description>
	<lastBuildDate>Fri, 10 Jul 2015 04:18:43 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>maxiFFT</title>
		<link>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifft</link>
		<comments>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifft#comments</comments>
		<pubDate>Wed, 08 Jul 2015 08:25:19 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[エフェクト]]></category>

		<guid isPermaLink="false">http://munetika.com/blog/?p=65</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifft/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>maxiFilter</title>
		<link>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifilter</link>
		<comments>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifilter#comments</comments>
		<pubDate>Wed, 08 Jul 2015 04:10:56 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[エフェクト]]></category>

		<guid isPermaLink="false">http://munetika.com/blog/?p=59</guid>
		<description><![CDATA[いわゆるフィルター。 一般的なものが最低限揃っている。 ソースを見る フィルタの実装 他にフィルタを実装してい [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>いわゆるフィルター。<br />
一般的なものが最低限揃っている。</p>
<h2>ソースを見る</h2>
<pre class="brush: cpp; title: maximilian.h; notranslate">
class maxiFilter { 	
	double gain;
	double input;
	double output;
	double inputs[10];
	double outputs[10];
	double cutoff1;
	double x;//speed
	double y;//pos
	double z;//pole
	double c;//filter coefficient
public:
	maxiFilter():x(0.0), y(0.0), z(0.0), c(0.0){};
	double cutoff;
	double resonance;
	double lores(double input,double cutoff1, double resonance);
	double hires(double input,double cutoff1, double resonance);
	double bandpass(double input,double cutoff1, double resonance);
	double lopass(double input,double cutoff);
	double hipass(double input,double cutoff);
	
};
</pre>
<pre class="brush: cpp; title: maximilian.cpp; notranslate">
//I particularly like these. cutoff between 0 and 1
double maxiFilter::lopass(double input, double cutoff) {
	output=outputs[0] + cutoff*(input-outputs[0]);
	outputs[0]=output;
	return(output);
}
//as above
double maxiFilter::hipass(double input, double cutoff) {
	output=input-(outputs[0] + cutoff*(input-outputs[0]));
	outputs[0]=output;
	return(output);
}
//awesome. cuttof is freq in hz. res is between 1 and whatever. Watch out!
double maxiFilter::lores(double input,double cutoff1, double resonance) {
	cutoff=cutoff1*0.5;
	if (cutoff&lt;10) cutoff=10;
	if (cutoff&gt;(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5);
	if (resonance&lt;1.) resonance = 1.;
	z=cos(TWOPI*cutoff/maxiSettings::sampleRate);
	c=2-2*z;
	double r=(sqrt(2.0)*sqrt(-pow((z-1.0),3.0))+resonance*(z-1))/(resonance*(z-1));
	x=x+(input-y)*c;
	y=y+x;
	x=x*r;
	output=y;
	return(output);
}

//working hires filter
double maxiFilter::hires(double input,double cutoff1, double resonance) {
	cutoff=cutoff1*0.5;
	if (cutoff&lt;10) cutoff=10;
	if (cutoff&gt;(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5);
	if (resonance&lt;1.) resonance = 1.;
	z=cos(TWOPI*cutoff/maxiSettings::sampleRate);
	c=2-2*z;
	double r=(sqrt(2.0)*sqrt(-pow((z-1.0),3.0))+resonance*(z-1))/(resonance*(z-1));
	x=x+(input-y)*c;
	y=y+x;
	x=x*r;
	output=input-y;
	return(output);
}

//This works a bit. Needs attention.
double maxiFilter::bandpass(double input,double cutoff1, double resonance) {
	cutoff=cutoff1;
	if (cutoff&gt;(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5);
	if (resonance&gt;=1.) resonance=0.999999;
	z=cos(TWOPI*cutoff/maxiSettings::sampleRate);
	inputs[0] = (1-resonance)*(sqrt(resonance*(resonance-4.0*pow(z,2.0)+2.0)+1));
	inputs[1] = 2*z*resonance;
	inputs[2] = pow((resonance*-1),2);
	
	output=inputs[0]*input+inputs[1]*outputs[1]+inputs[2]*outputs[2];
	outputs[2]=outputs[1];
	outputs[1]=output;
	return(output);
}

</pre>
<h2>フィルタの実装</h2>
<p>他にフィルタを実装しているライブラリを見て<br />
参考にしようと探したところ<br />
Robert Bristow-Johnsonという方が<a href="http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt" target="_blank">「RBJ Audio EQ Cookbook」</a>というテキストにまとめているようだ。<br />
説明は下記がわかりやすい。</p>
<ul>
<li><a href="http://vstcpp.wpblog.jp/?page_id=523" target="_blank">簡単なデジタルフィルタの実装</a></li>
<li><a href="http://ufcpp.net/study/sp/digital_filter/biquad" target="_blank">[ディジタルフィルタ] 双2次フィルタ</a></li>
</ul>
<p>上記を参考にソースを追ってみたい。</p>
<h2>関数を読み解く</h2>
<p>と、いろいろ調べていたところで<br />
どうもMaximilianのローパス・ハイパスフィルタはもっとお手軽に実装しているようだ。</p>
<pre class="brush: cpp; title: lopass/hipass filter; notranslate">
//I particularly like these. cutoff between 0 and 1
double maxiFilter::lopass(double input, double cutoff) {
	output=outputs[0] + cutoff*(input-outputs[0]);
	outputs[0]=output;
	return(output);
}
//as above
double maxiFilter::hipass(double input, double cutoff) {
	output=input-(outputs[0] + cutoff*(input-outputs[0]));
	outputs[0]=output;
	return(output);
}
</pre>
<p>output[0] + cutoff*(input-output[0])<br />
となっている。<br />
これは、加算平均というデジタルフィルタで、主にノイズの除去に使われている<br />
計算に似ている。<br />
しかし加算平均であれば<br />
output[0]*(1-cutoff) + cuoff*(input-output[0])<br />
とすべきだが、それをもっとお手軽にした形なのだろう。<br />
ま、そういうものということで、この二つはいいかと思う。</p>
<p>次にlores,hiresをみよう。</p>
<pre class="brush: cpp; title: lopass/hipass filter; notranslate">
//awesome. cuttof is freq in hz. res is between 1 and whatever. Watch out!
double maxiFilter::lores(double input,double cutoff1, double resonance) {
	cutoff=cutoff1*0.5;
	if (cutoff&lt;10) cutoff=10;
	if (cutoff&gt;(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5);
	if (resonance&lt;1.) resonance = 1.;
	z=cos(TWOPI*cutoff/maxiSettings::sampleRate);
	c=2-2*z;
	double r=(sqrt(2.0)*sqrt(-pow((z-1.0),3.0))+resonance*(z-1))/(resonance*(z-1));
	x=x+(input-y)*c;
	y=y+x;
	x=x*r;
	output=y;
	return(output);
}

//working hires filter
double maxiFilter::hires(double input,double cutoff1, double resonance) {
	cutoff=cutoff1*0.5;
	if (cutoff&lt;10) cutoff=10;
	if (cutoff&gt;(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5);
	if (resonance&lt;1.) resonance = 1.;
	z=cos(TWOPI*cutoff/maxiSettings::sampleRate);
	c=2-2*z;
	double r=(sqrt(2.0)*sqrt(-pow((z-1.0),3.0))+resonance*(z-1))/(resonance*(z-1));
	x=x+(input-y)*c;
	y=y+x;
	x=x*r;
	output=input-y;
	return(output);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxifilter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>maxiEnvelope</title>
		<link>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxienvelope</link>
		<comments>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxienvelope#comments</comments>
		<pubDate>Tue, 07 Jul 2015 12:25:15 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[エフェクト]]></category>

		<guid isPermaLink="false">http://munetika.com/blog/?p=41</guid>
		<description><![CDATA[maximilianには二つのエンベロープが存在する そのうちの一つmaxiEnvelopeは最大1000個ま [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>maximilianには二つのエンベロープが存在する<br />
そのうちの一つmaxiEnvelopeは最大1000個までのアンカーポイントを打てて、<br />
それぞれの間をリニアにつなぐシンプルなエンベロープである。<br />
もう一つのmaxEnvはadsrを使ったもののようである。</p>
<h2>ソースを見る</h2>
<pre class="brush: cpp; title: maximilian.h; notranslate">
class maxiEnvelope {
	
	double period;
	double output;
	double startval;
	double currentval;
	double nextval;
	int isPlaying;
	
public:	
	double line(int numberofsegments,double segments[100]);
	void trigger(int index,double amp);
	int valindex;
	double amplitude;
	
};
</pre>
<pre class="brush: plain; title: maximilian.cpp; notranslate">
//I like this.
double maxiEnvelope::line(int numberofsegments,double segments[1000]) {
	if (isPlaying==1) {//only make a sound once you've been triggered
		
		period=2./(segments[valindex+1]*0.004);
		nextval=segments[valindex+2];
		currentval=segments[valindex];
		if (currentval-amplitude &gt; 0.0000001 &amp;&amp; valindex &lt; numberofsegments) {
			amplitude += ((currentval-startval)/(maxiSettings::sampleRate/period));
		} else if (currentval-amplitude &lt; -0.0000001 &amp;&amp; valindex &lt; numberofsegments) {
			amplitude -= (((currentval-startval)*(-1))/(maxiSettings::sampleRate/period));
		} else if (valindex &gt;numberofsegments-1) {
			valindex=numberofsegments-2;
		} else {
			valindex=valindex+2;
			startval=currentval;
		}
		output=amplitude;
		
	}
	else {
		output=0;
		
	}
	return(output);
}

//and this
void maxiEnvelope::trigger(int index, double amp) {
	isPlaying=1;//ok the envelope is being used now.
	valindex=index;
	amplitude=amp;
	
}
</pre>
<h2>関数を読み解く</h2>
<p>関数は二つあるが、triggerはセットされたエンベロープをスタート・リセットさせるだけなので<br />
lineを読み解く。</p>
<p>lineのsegmentsには、その配列の個数と値とステップ数を交互に入れたものを渡す。<br />
{値、ステップ数、値、ステップ数、、、}<br />
という具合だ。<br />
値もステップ数も、前の値に関係なく絶対値だ。<br />
ステップ数は秒でもミリ秒でもなく、<br />
サンプリングレート等を考えて求める必要がある。</p>
<p>いまいち、step数が直感的でなく分かりづらいので、コードを追ってみたい。<br />
5行目の部分</p>
<pre class="brush: cpp; title: ; notranslate">
period=2./(segments[valindex+1]*0.004);
</pre>
<p>ここは、前の値からの増加期間を計算しているようだ。<br />
9行目、11行目と関わってくる</p>
<pre class="brush: cpp; title: ; notranslate">
amplitude += ((currentval-startval)/(maxiSettings::sampleRate/period));
</pre>
<p>サンプリングレートをperiodで割っている。<br />
9,11行目の分子の部分が44100となると1秒、22050となると0.5秒で<br />
目的の値になるのがわかるので、ここの値を求めてみたい。<br />
実際にstep数を代入して計算してみる</p>
<p>maxSetting::sampleRateは44100とする</p>
<p>segments[valindex+1] = 1000の場合<br />
period = 2./(1000*0.004);<br />
period = 0.5<br />
44100/0.5<br />
=88200となる<br />
つまり88200/44100=2で、2秒ということになる。<br />
&#8212;<br />
segments[valindex+1] = 500の場合<br />
period = 2./(500*0.004);<br />
period = 1.0<br />
44100/1.0<br />
=44100となる<br />
つまり44100/44100=1で、1秒ということになる。</p>
<p>で<br />
segments[valindex+1] = 250の場合<br />
0.5秒<br />
segments[valindex+1] = 2000の場合<br />
4秒</p>
<p>となり<br />
まとめると<br />
2000の時4秒<br />
1000の時2秒<br />
500の時1秒<br />
250の時0.5秒</p>
<p>で500で1秒と考えれば良さそう。</p>
<p>ただ気持ち悪い場合は0.004の部分を0.002にすれば<br />
ミリ秒で考えられそうですね。</p>
<h2>使ってみる</h2>
<p>適当なキーを押すとトリガーになって、円が描画されます。</p>
<pre class="brush: cpp; title: testApp.h; notranslate">
#pragma once
#include &quot;ofMain.h&quot;
#include &quot;ofxMaxim.h&quot;

class testApp : public ofBaseApp {

	public:
		~testApp();/* destructor is very useful */
		void setup();
		void update();
		void draw();

		void keyPressed  (int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
	
		void audioRequested 	(float * input, int bufferSize, int nChannels); /* output method */
		void audioReceived 	(float * input, int bufferSize, int nChannels); /* input method */
	
		int		initialBufferSize; /* buffer size */
		int		sampleRate;
	
		/* stick you maximilian stuff below */
        double sample;
        ofxMaxiEnvelope envelope;
};
</pre>
<pre class="brush: cpp; title: testApp.cpp; notranslate">
#include &quot;testApp.h&quot;

double env[8]={20,0, 0,500, 250,1000, 40,250};

//-------------------------------------------------------------
testApp::~testApp() {
}

//--------------------------------------------------------------
void testApp::setup(){
	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
	
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
	
	ofSoundStreamSetup(2,0,this, sampleRate, initialBufferSize, 4);/* Call this last ! */
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
	ofSetColor(255, 255, 255,255);
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, sample);
	
}
//--------------------------------------------------------------
void testApp::audioRequested 	(float * output, int bufferSize, int nChannels){
	for (int i = 0; i &lt; bufferSize; i++){
        sample = envelope.line(8, env);
	}
}
//--------------------------------------------------------------
void testApp::audioReceived 	(float * input, int bufferSize, int nChannels){	
	for (int i = 0; i &lt; bufferSize; i++){}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    envelope.trigger(0, env[0]);
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){ 
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/maxienvelope/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>maxiDelayline</title>
		<link>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/hello-world</link>
		<comments>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/hello-world#comments</comments>
		<pubDate>Mon, 06 Jul 2015 11:09:18 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[エフェクト]]></category>

		<guid isPermaLink="false">http://munetika.com/blog/cms/?p=1</guid>
		<description><![CDATA[ソースを見る まずはコードをmaxiDelaylineクラスの部分だけ抜き出して見てみる たったこれだけ。 バ [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>ソースを見る</h2>
<p>まずはコードをmaxiDelaylineクラスの部分だけ抜き出して見てみる</p>
<pre class="brush: cpp; title: maximilian.h; notranslate">
class maxiDelayline {
	double frequency;
	int phase;
	double startphase;
	double endphase;
	double output;
	double memory[88200];
	
public:
	maxiDelayline();
	double dl(double input, int size, double feedback);
	double dl(double input, int size, double feedback, int position);
	
	
};
</pre>
<pre class="brush: cpp; title: maximilian.cpp; notranslate">
//Delay with feedback
maxiDelayline::maxiDelayline() {
	memset( memory, 0, 88200*sizeof (double) );
    phase=0;
}


double maxiDelayline::dl(double input, int size, double feedback)  {
	if ( phase &gt;=size ) {
		phase = 0;
	}
	output=memory[phase];
	memory[phase]=(memory[phase]*feedback)+(input*feedback)*0.5;
	phase+=1;
	return(output);
	
}

double maxiDelayline::dl(double input, int size, double feedback, int position)  {
	if ( phase &gt;=size ) phase = 0;
	if ( position &gt;=size ) position = 0;
	output=memory[position];
	memory[phase]=(memory[phase]*feedback)+(input*feedback)*chandiv;
	phase+=1;
	return(output);
	
}
</pre>
<p>たったこれだけ。<br />
バッファで用意されているのが、一秒間44100Hzとすると2秒分用意されている。</p>
<h2>関数を読み解く</h2>
<p>dl関数が二つ用意されていいるが、基本的に中身は一緒なので、より簡単な方で見ていこう。
</p>
<pre class="brush: cpp; title: ; notranslate">
double maxiDelayline::dl(double input, int size, double feedback)  {
	if ( phase &gt;=size ) {
		phase = 0;
	}
	output=memory[phase];
	memory[phase]=(memory[phase]*feedback)+(input*feedback)*0.5;
	phase+=1;
	return(output);
}
</pre>
<p>上記は簡易的なリングバッファを使ったディレイと考えられる。<br />
88200個のバッファに順に書き込まれ、終わりが来たらまた頭に戻る。<br />
ただそれだけだ。<br />
そして、書き込むと同時にアウトプットの値も返ってくる。</p>
<p>引数で注意したいのはsizeで、この値は88200を超えないことが暗黙の了解のようだ。<br />
dlを呼ぶたびにphaseの値はインクリメントされinputの値とバッファがfeedbackの割合で加算される。その時inputの値は0.5倍される。<br />
決めうちの値が多いが、初心者にとってはこのぐらいの方が使いやすい。<br />
配列を渡すのではなく、ループでそれぞれの値を渡す形になっている<br />
ここら辺気持ち悪ければ、関数をオーバーロードして配列を渡すようにしてもいいかもしれない。</p>
<h2>使ってみる</h2>
<p>下記は、ループ音源を使ったサンプル。<br />
マウスのx座標でバッファのサイズを0~88200まで変化するようにした。<br />
0だと、ディレイのない音で10,000を超えたぐらいからおかしくなる感じだ。<br />
大体、4000~8000ぐらいが良さそうな感じ。</p>
<pre class="brush: cpp; title: testApp.h; notranslate">
#pragma once

#include &quot;ofMain.h&quot;
#include &quot;ofxMaxim.h&quot;


class testApp : public ofBaseApp{

	public:
		~testApp();/* destructor is very useful */
		void setup();
		void update();
		void draw();

		void keyPressed  (int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
	
		void audioRequested 	(float * input, int bufferSize, int nChannels); /* output method */
		void audioReceived 	(float * input, int bufferSize, int nChannels); /* input method */
	
		int		initialBufferSize; /* buffer size */
		int		sampleRate;
	
	
		/* stick you maximilian stuff below */
	
		double sample,size,outputs[2];
		ofxMaxiMix mymix;
		ofxMaxiSample beat;
	
        ofxMaxiDelayline delay;
};
</pre>
<pre class="brush: cpp; title: testApp.cpp; notranslate">
/* This is an example of how to integrate maximilain into openFrameworks, 
 including using audio received for input and audio requested for output.
 
 
 You can copy and paste this and use it as a starting example.
 
 */


#include &quot;testApp.h&quot;


//-------------------------------------------------------------
testApp::~testApp() {
	
	/*delete beat.myData;*/ /*you should probably delete myData for any sample object
						 that you've created in testApp.h*/
	
}


//--------------------------------------------------------------
void testApp::setup(){
    
	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
	
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
	
	beat.load(ofToDataPath(&quot;beat2.wav&quot;));
	beat.getLength();
	
	ofSoundStreamSetup(2,0,this, sampleRate, initialBufferSize, 4);/* Call this last ! */
}

//--------------------------------------------------------------
void testApp::update(){
	
}

//--------------------------------------------------------------
void testApp::draw(){
	
	ofSetColor(255, 255, 255,255);
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, sample*150);
	
}

//--------------------------------------------------------------
void testApp::audioRequested 	(float * output, int bufferSize, int nChannels){
	
	for (int i = 0; i &lt; bufferSize; i++){
		
		sample=delay.dl(beat.play(0.25, 0, beat.length),size,0.5);
		mymix.stereo(sample, outputs, 0.5);
		
		output[i*nChannels    ] = outputs[0]; /* You may end up with lots of outputs. add them here */
		output[i*nChannels + 1] = outputs[1];
	}
	
}

//--------------------------------------------------------------
void testApp::audioReceived 	(float * input, int bufferSize, int nChannels){	
	
	
	/* You can just grab this input and stick it in a double, then use it above to create output*/
	
	for (int i = 0; i &lt; bufferSize; i++){
		
		/* you can also grab the data out of the arrays*/
		
		
	}
	
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
	
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){
	
}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
    size = ((double)ofGetMouseX()/(double)ofGetWidth()) * 88200.f;
    if(size &lt; 0)
        size=0;
    if(size &gt; 88200)
        size = 88200;
    printf(&quot;size:%f\n&quot;,size);
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
	
}



//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){ 

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://munetika.com/blog/%e3%82%a8%e3%83%95%e3%82%a7%e3%82%af%e3%83%88/hello-world/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
