Autor Beitrag
sisc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D3 Prof
BeitragVerfasst: Sa 19.03.05 17:25 
Wie kann ich den Line-In Anschluss ansteuern?
Wie kann ich die Signale dann auswerten (für ein Diagramm)?

Danke, fürs Helfen!

sisc :?:
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Sa 19.03.05 17:29 
user profile iconsisc hat folgendes geschrieben:
Wie kann ich den Line-In Anschluss ansteuern?

Ich glaube nicht, dass du das kannst; weiß ich aber nicht sicher
user profile iconsisc hat folgendes geschrieben:
Wie kann ich die Signale dann auswerten (für ein Diagramm)?

Immer wieder schön :twisted: www.math.tu-cottbus..../hmetmbvt3/mathe.pdf. Bist du sicher, dass du das noch immer machen willst :mrgreen:

AXMD
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: Sa 19.03.05 18:16 
mit der bass.dll fft ist da schon integriert. Such mal im forum nachbeiträgen zu dem thema.

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: Sa 19.03.05 19:53 
Hier ist anoch der passende link.
www.dsdt.info/YaBBSe...hreadid=21755;start=

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
Lossy eX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1048
Erhaltene Danke: 4



BeitragVerfasst: So 20.03.05 11:10 
Ich habe das in einem Projekt auch schon mal gemacht. Allerdings ganz ohne Bass.

@AXMD: Für so etwas gibt es doch unmassen vorgefertigter Quellen. Man muss nicht immer alles selber machen. ;-)

_________________
Nur die Menschheit ist arrogant genug, um zu glauben sie sei die einzige intelligente Lebensform im All. Wo nicht mal das nachhaltig bewiesen wurde.
sisc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D3 Prof
BeitragVerfasst: Mo 21.03.05 16:44 
Hi!
Kann mir jemand eine Tipp geben, wie man die Komponenten benützt?
sisc :?:
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: Mo 21.03.05 19:10 
wie wäre es mal das zulesen was sich geschrieben habe.

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
sisc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D3 Prof
BeitragVerfasst: Mi 23.03.05 10:25 
Entschuldigung, ich habe die Frage wohl etwas falsch formuliert.
Ich wollte eigentlich, wenn es geht ohne DLL arbeiten (nur im Notfall).
Deshalb wollte ich fragen, ob mir jemand sagen kann, wie man das, was vom Line-In kommt an diese Prozedure übergeben kann, und wie man dann die Werte bekommt, :lupe: benützen kann (z.B. Diagramm).
Das ist jetzt die Unit die beim VU-Meter Source dabei war. Bei der VU-Meter Source habe ich ein bisschen Schwierigkeiten, was rauszulesen, weil so viel OpenGL dabei ist, und ich das nicht kann.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
{$N+,E+}   (* Allows code to use type 'double' and run on any iX86 machine *)
{$R-}      (* Turn off range checking...we violate array bounds rules *)
unit Fourier;


interface

(*---------------------------------------------------------------------------
  procedure fft

  Calculates the Fast Fourier Transform of the array of complex numbers
  represented by 'RealIn' and 'ImagIn' to produce the output complex
  numbers in 'RealOut' and 'ImagOut'.
---------------------------------------------------------------------------*)

procedure fft (
  NumSamples:   word;   { must be a positive integer power of 2 }
  var  RealIn:   array of double;
  var  ImagIn:   array of double;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );


(*---------------------------------------------------------------------------
  procedure ifft

  Calculates the Inverse Fast Fourier Transform of the array of complex
  numbers represented by 'RealIn' and 'ImagIn' to produce the output complex
  numbers in 'RealOut' and 'ImagOut'.
---------------------------------------------------------------------------*)

procedure ifft (
  NumSamples:   word;   { must be a positive integer power of 2 }
  var  RealIn:   array of double;
  var  ImagIn:   array of double;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );



(*---------------------------------------------------------------------------
  procedure fft_integer

  Same as procedure fft, but uses integer input arrays instead of
  double.  Make sure you call fft_integer_cleanup after the last
  time you call fft_integer to free up memory it allocates.
---------------------------------------------------------------------------*)

procedure fft_integer (
  NumSamples:   word;
  var  RealIn:   array of integer;
  var  ImagIn:   array of integer;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );


(*--------------------------------------------------------------------------
   procedure fft_integer_cleanup

   If you call the procedure 'fft_integer', you must call
   'fft_integer_cleanup' after the last time you call 'fft_integer'
   in order to free up dynamic memory.
--------------------------------------------------------------------------*)

procedure fft_integer_cleanup;


(*--------------------------------------------------------------------------
   procedure CalcFrequency

   This procedure calculates the complex frequency sample at a given
   index directly.  Use this instead of 'fft' when you only need one
   or two frequency samples, not the whole spectrum.

   It is also useful for calculating the Discrete Fourier Transform (DFT)
   of a number of data which is not an integer power of 2.  For example,
   you could calculate the DFT of 100 points instead of rounding up to
   128 and padding the extra 28 array slots with zeroes.
--------------------------------------------------------------------------*)

procedure CalcFrequency (
  NumSamples: word;       { can be any positive integer }
  FrequencyIndex: word;   { must be in the range 0 .. NumSamples-1 }
  var  RealIn:  array of double;
  var  ImagIn:  array of double;
  var  RealOut: double;
  var  ImagOut: double );


implementation



type
  doubleArray = array [0..0] of double;
var
  RealTemp, ImagTemp: ^doubleArray;
  TempArraySize:  word;



function IsPowerOfTwo ( x: word ): boolean;
var
  i, y:  word;
begin
  y := 2;
  for i := 1 to 15 do begin
    if x = y then begin
      IsPowerOfTwo := TRUE;
      exit;
    end;
    y := y SHL 1;
  end;

  IsPowerOfTwo := FALSE;
end;



function NumberOfBitsNeeded ( PowerOfTwo: word ): word;
var
  i: word;
begin
  result := 0;
  for i := 0 to 16 do begin
    if (PowerOfTwo AND (1 SHL i)) <> 0 then begin
      Result := i;
      exit;
    end;
  end;
end;



function ReverseBits ( index, NumBits: word ): word;
var
  i, rev: word;
begin
  rev := 0;
  for i := 0 to NumBits-1 do begin
    rev := (rev SHL 1) OR (index AND 1);
    index := index SHR 1;
  end;

  ReverseBits := rev;
end;



procedure FourierTransform (
  AngleNumerator:  double;
  NumSamples:   word;
  var  RealIn:   array of double;
  var  ImagIn:   array of double;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );
var
  NumBits, i, j, k, n, BlockSize, BlockEnd: word;
  delta_angle, delta_ar: double;
  alpha, beta: double;
  tr, ti, ar, ai: double;
begin
  if not IsPowerOfTwo(NumSamples) or (NumSamples<2) then begin
    write ( 'Error in procedure Fourier:  NumSamples=', NumSamples );
    writeln ( ' is not a positive integer power of 2.' );
    halt;
  end;

  NumBits := NumberOfBitsNeeded (NumSamples);
  for i := 0 to NumSamples-1 do begin
    j := ReverseBits ( i, NumBits );
    RealOut[j] := RealIn[i];
    ImagOut[j] := ImagIn[i];
  end;

  BlockEnd := 1;
  BlockSize := 2;
  while BlockSize <= NumSamples do begin
    delta_angle := AngleNumerator / BlockSize;
    alpha := sin ( 0.5 * delta_angle );
    alpha := 2.0 * alpha * alpha;
    beta := sin ( delta_angle );

    i := 0;
    while i < NumSamples do begin
      ar := 1.0;    (* cos(0) *)
      ai := 0.0;    (* sin(0) *)

      j := i;
      for n := 0 to BlockEnd -1 do begin
        k := j + BlockEnd;
        tr := ar*RealOut[k] - ai*ImagOut[k];
        ti := ar*ImagOut[k] + ai*RealOut[k];
        RealOut[k] := RealOut[j] - tr;
        ImagOut[k] := ImagOut[j] - ti;
        RealOut[j] := RealOut[j] + tr;
        ImagOut[j] := ImagOut[j] + ti;
        delta_ar := alpha*ar + beta*ai;
        ai := ai - (alpha*ai - beta*ar);
        ar := ar - delta_ar;
        INC(j);
      end;

      i := i + BlockSize;
    end;

    BlockEnd := BlockSize;
    BlockSize := BlockSize SHL 1;
  end;
end;



procedure fft (
  NumSamples:   word;
  var  RealIn:   array of double;
  var  ImagIn:   array of double;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );
begin
  FourierTransform ( 2*PI, NumSamples, RealIn, ImagIn, RealOut, ImagOut );
end;



procedure ifft (
  NumSamples:   word;
  var  RealIn:   array of double;
  var  ImagIn:   array of double;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );
var
  i: word;
begin
  FourierTransform ( -2*PI, NumSamples, RealIn, ImagIn, RealOut, ImagOut );

  (* Normalize the resulting time samples... *)
  for i := 0 to NumSamples-1 do begin
    RealOut[i] := RealOut[i] / NumSamples;
    ImagOut[i] := ImagOut[i] / NumSamples;
  end;
end;



procedure fft_integer (
  NumSamples:   word;
  var  RealIn:   array of integer;
  var  ImagIn:   array of integer;
  var  RealOut:  array of double;
  var  ImagOut:  array of double );
var
  i: word;
begin
  if NumSamples > TempArraySize then begin
    fft_integer_cleanup;  { free up memory in case we already have some. }
    GetMem ( RealTemp, NumSamples * sizeof(double) );
    GetMem ( ImagTemp, NumSamples * sizeof(double) );
    TempArraySize := NumSamples;
  end;

  for i := 0 to NumSamples-1 do begin
    RealTemp^[i] := RealIn[i];
    ImagTemp^[i] := ImagIn[i];
  end;

  FourierTransform (2*PI, NumSamples, RealTemp^, ImagTemp^, RealOut, ImagOut);
end;



procedure fft_integer_cleanup;
begin
  if TempArraySize > 0 then begin
    if RealTemp <> NIL then begin
      FreeMem ( RealTemp, TempArraySize * sizeof(double) );
      RealTemp := NIL;
    end;

    if ImagTemp <> NIL then begin
      FreeMem ( ImagTemp, TempArraySize * sizeof(double) );
      ImagTemp := NIL;
    end;

    TempArraySize := 0;
  end;
end;



procedure CalcFrequency (
  NumSamples: word;       { must be integer power of 2 }
  FrequencyIndex: word;   { must be in the range 0 .. NumSamples-1 }
  var  RealIn:  array of double;
  var  ImagIn:  array of double;
  var  RealOut: double;
  var  ImagOut: double );
var
  k: word;
  cos1, cos2, cos3, theta, beta: double;
  sin1, sin2, sin3: double;
begin
  RealOut := 0.0;
  ImagOut := 0.0;
  theta := 2*PI * FrequencyIndex / NumSamples;
  sin1 := sin ( -2 * theta );
  sin2 := sin ( -theta );
  cos1 := cos ( -2 * theta );
  cos2 := cos ( -theta );
  beta := 2 * cos2;
  for k := 0 to NumSamples-1 do begin
    { Update trig values }
    sin3 := beta*sin2 - sin1;
    sin1 := sin2;
    sin2 := sin3;

    cos3 := beta*cos2 - cos1;
    cos1 := cos2;
    cos2 := cos3;

    RealOut := RealOut + RealIn[k]*cos3 - ImagIn[k]*sin3;
    ImagOut := ImagOut + ImagIn[k]*cos3 + RealIn[k]*sin3;
  end;
end;



begin  { Unit initialization code }
  TempArraySize := 0; {flag that buffers RealTemp, RealImag not allocated}
  RealTemp := NIL;
  ImagTemp := NIL;
end.


Danke für eure Hilfe!
sisc :?:

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Gandalfus
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 129



BeitragVerfasst: Mi 23.03.05 19:07 
user profile iconsisc hat folgendes geschrieben:
Entschuldigung, ich habe die Frage wohl etwas falsch formuliert.
Ich wollte eigentlich, wenn es geht ohne DLL arbeiten (nur im Notfall).


Der Code von Lossy eX funktioniert auf meinem Rechner garnicht...
Das hängt glaube ich mit der Soundkarte zusammen(Ob die Soundkarte das unterstützt).
Die bass.dll oder auch fmod sind nunmal die einfachsten Lösungen.

Du kannst natürlich auch direkt mit DirectSound arbeiten aber das nicht so leicht.

_________________
Wennn man feststellt, dass es drei Moeglichkeiten gibt, die einen Vorgang schiefgehen lassen koennen und man diese ausschaltet, entstehen automatisch drei neue Moeglichkeiten.
sisc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D3 Prof
BeitragVerfasst: Do 24.03.05 16:41 
@Gandalfus

Ich bin dabei die DLL auszuprobieren. Ich habe auf die Seite
Zitat:

Hier ist anoch der passende link.
www.dsdt.info/YaBBSe...hreadid=21755;start=

geschaut und will die DLL ausprobieren. Ich weiß nur nicht, wie man die DLL initialisiert.
Ich würde es viel lieber ohne DLL machen, um es dann auch z.B. unter Linux zu kompilieren.

Danke für Eure Hilfe
sisc :?:
sisc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D3 Prof
BeitragVerfasst: So 10.04.05 15:23 
Ich habe mein Problem gelöst. Danke für Euere Hilfe!
sisc :idea: