📄 fft-spectra.h
字号:
#ifndef __FFT_SPECTRA_H__#define __FFT_SPECTRA_H__#include <stdarg.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <errno.h>#include <unistd.h>#include <gtk/gtk.h>#include <esd.h>#include "conf.h"typedef struct{ float freq; float idata; char *label; GdkGC *gc;}linetag_t;extern int esd_rate; /* Sampling rate of the esd sound daemon */extern int bps; /* Bytes per sample */extern int channels; /* Channels (mono=1, stereo=2) */extern int signed_data; /* Are the sound data signed or unsigned? */extern int ndata_in; /* Number of data points going to the FFT engine */extern int ndata_out; /* Number of valid data points coming from FFT engine is not equal to ndata_in, it is actually ndata_in/2+1. */extern float *data; /* The data obtained from the reader, already parsed as necessary */extern int refresh_rate; /* Refresh rate of the screen */extern float dfreq; /* A frequency difference between two consecutive data points */extern int do_not_play; /* Read the sound file and display it only, but do not play it */extern int *sound_data_end; /* Pointer to shared memory - where is the end of the data in the round-buffer. See fft-spectra.c in sound_data_client_record(void). */#define MSG_OK 0#define MSG_EXIT_REQUEST 1#define MSG_PAUSE_REQUEST 3#define MSG_ECHO_REQUEST 4 /* For debug purposes */extern int *msg_from_gui, /* Interprocess communication between the GUI and the reader. */ *msg_from_reader; extern char *sound_data_buffer; /* The round-buffer with readed sound data */extern int sound_data_size; /* The size of the round-buffer */extern int esd_stream_rec; /* The socket for recording - it is here to be available also from main. */extern int esd_stream_play; /* The socket for playing */extern int file_stream; /* For reading sound data from a file */extern char *config_file; extern char *settings; /* The name of the profile to use */extern int view_grid; /* Whether the vertical grid should be drawn */extern int view_custom_grid; /* Whether the custom linetags should be drawn */extern int main_width, /* Dimensions of the main display window */ main_height;extern int scalebar_height, /* The dimensions of the bottom scalebar */ scalebar_width; extern int side_scalebar_width; /* The width of the side scalebar */extern GdkGC *gc_select; /* Graphic context for the selection rectangle */#define REFRESH_NONE 0 /* Avoid redrawing everything, only what is really needed. */#define REFRESH_SCALEBAR 1#define REFRESH_SELECTION 2#define REFRESH_FFT_SAMPLE 4#define REFRESH_POINTER_SCALEBAR 8#define REFRESH_FFT_STOP 16#define REFRESH_ALL (1|4|8)#define REFRESH_SIDE_SCALEBAR 32extern int refresh_status;#define MODE_FOURIER 1 /* Display mode: Frequency analysis */#define MODE_SPECTROGRAM 2 /* - Real spectrogram (time history) */#define MODE_WAVES 3 /* - Display the sound wave */extern int mode;#define INTENSITY_SCALE_CONSTANT 1 /* Intensity scale - total maxima remembered */#define INTENSITY_SCALE_FLEXIBLE 2 /* - Scale to the current maxima (amplifies silence noise) */#define INTENSITY_SCALE_SMART 3 /* - Scale to the current maxima, but only up to some threshold */extern int intensity_scale_mode;#define BUFLEN 255 /* For holding temporary strings */#define SB_MARGIN 2 /* Margins for drawing the scalebar ruler */#define DEBUG 1#ifdef DEBUG# define ASSERT(x) { if(!(x))exit_nicely("Assert failed on %s:%d\n",__FILE__,__LINE__); }#else# define ASSERT(x)#endif#define MALLOC(ptr,type,size) { (ptr)=malloc(sizeof(type)*(size)); \ if(!(ptr)) exit_nicely("%s:%d Could not malloc %d bytes.\n",__FILE__,__LINE__,size); }#define FREE(ptr) { free(ptr); (ptr)=NULL; }void exit_nicely(const char *format, ...);void init(char *custom_settings);void init_fft(int nsamples);void get_fft_sample(int nsamples, float *buffer, int max_from,int max_to,float *min,float *max,int logscale);void get_data_sample(int nsamples, int *buffer, int *min, int *max, int *pos_max);int get_data_sample_fft_max(int nsamples, int *sound_data, int *min, int *max, int *pos_max);void sound_data_client_record(void);void sound_data_client_play_file(void);void finish_fft(void);void open_sound_file_stream(void);GdkGC *get_gc(const char *color_string);GdkGC *get_gc_new(const char *color_string);linetag_t *get_new_tag(float freq,char *label,char *color);inline float freq_to_idata(float freq);inline float idata_to_freq(float idata);inline float idata_to_pixel(float idata,float width);inline float pixel_to_idata(float pixel,float width);/* Fourier display mode */void fourier_gtk_configure(void);void fourier_read_profile(int *width, int *height);void fourier_main_draw(GdkPixmap *pixmap, int width,int height);void fourier_grid_toggle(void);void fourier_display_type_toggle(void);void fourier_logarithmic_intensity_toggle(void);/* Spectrogram display mode */void spectrogram_gtk_configure(GtkWidget *widget);void spectrogram_read_profile(int *width, int *height);void spectrogram_main_draw(GdkPixmap *pixmap, int width,int height);void spectrogram_clean_screen(void);void spectrogram_init_intensity(void);void spectrogram_set_main_pixmap(GdkPixmap *pixmap);void spectrogram_draw_side_scalebar(GdkPixmap *pixmap, int width,int height);void spectrogram_interpolate_toggle(void);void spectrogram_logarithmic_intensity_toggle(void);/* Waves display mode */void waves_read_profile(int *width, int *height);void waves_main_draw(GdkPixmap *pixmap, int width,int height);void waves_gtk_configure(void);void waves_zoom_out(void);void waves_zoom_in(void);void waves_zoom_restore(void);void waves_init_intensity(void);/* Default handlers common to more display modes */void default_scalebar_draw(GdkPixmap *pixmap, int width,int height);void default_scalebar_pointer_draw(GdkPixmap *pixmap, int width,int height,float x);void default_zoom_restore(void);void default_zoom_event(float pressed_x, float released_x);void default_zoom_in(void);void default_zoom_out(void);void default_zoom_out_total(void);void default_move_left(void);void default_move_right(void);void default_custom_grid_toggle(void);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -