diff --git a/ChangeLog b/ChangeLog index eb20ee8d21..80ffc5fbe5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,66 @@ +2005-11-29 Tobias Doerffel + + * plugins/vestige/vestige.h: + * plugins/vestige/vestige.cpp: + changes for working with new VST-framework + + * plugins/vestige/fstclient.h: + * plugins/vestige/fstserver.h: + * plugins/vestige/fstclient.cpp: + * plugins/vestige/fstserver.cpp: + * plugins/vestige/fstcore.c: + * plugins/vestige/communication.h: + added new VST-framework (client-server-architecture) based on XFST + + * include/qxembed.h + * src/widgets/qxembed.cpp: + added QXEmbed-widget which is neccessary for embedding VST-plugin + +2005-11-27 Tobias Doerffel + + * src/core/mixer.cpp: + added usleep()-call for realizing usable threading and solve problems + with 100%-CPU-usage + +2005-11-08 Tobias Doerffel + + * include/channel_track.h: + * include/sample_play_handle.h: + * include/sample_track.h: + * src/core/sample_play_handle.cpp: + * src/tracks/channel_track.cpp: + * src/tracks/sample_track.cpp: + made things work with audio-ports + + * include/mixer.h: + * src/core/mixer.cpp: + completely revised internal mixing-engine make it working with + the new audio-ports, which results in a much cleaner, faster and more + powerful mixing-engine + + * include/audio_port.h: + * src/audio/audio_port.cpp: + added so called audio-ports which are important for transporting sound + from it's origin through the mixer and the effect-board (the latter + one isn't existing yet but coming quite soon) - another important + point is ability of having output-ports for each channel/sample-track + with JACK + + * src/tracks/channel_track.cpp: + translate default-channel-name "Default" + + * src/audio/audio_jack.cpp: + - sync JACK's buffer-size with LMMS's one + - start JACK-transport if not already done + + * include/mixer.h: + * src/audio/audio_jack.cpp: + * src/core/mixer.cpp: + * src/lib/sample_buffer.cpp: + * src/widgets/visualization_widget.cpp: + use memset() for clearing buffers - obsoletes usage of silence-buffers + in mixer + 2005-11-07 Tobias Doerffel * src/midi/midi_alsa_seq.cpp: diff --git a/Makefile.am b/Makefile.am index 41043297c7..e6a2023b56 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ endif SUBDIRS = artwork buildtools locale midi-maps plugins presets projects samples -INCLUDES = -I$(srcdir)/include -I. +INCLUDES = -I$(srcdir)/include -I. -I/usr/include/wine -I/usr/include/wine/windows bin_PROGRAMS = lmms @@ -70,6 +70,7 @@ lmms_MOC = \ ./pixmap_button.moc \ ./plugin_browser.moc \ ./project_notes.moc \ + ./qxembed.moc \ ./rename_dialog.moc \ ./sample_buffer.moc \ ./sample_track.moc \ @@ -106,6 +107,7 @@ lmms_SOURCES = \ $(srcdir)/src/audio/audio_file_wave.cpp \ $(srcdir)/src/audio/audio_jack.cpp \ $(srcdir)/src/audio/audio_oss.cpp \ + $(srcdir)/src/audio/audio_port.cpp \ $(srcdir)/src/audio/audio_sample_recorder.cpp \ $(srcdir)/src/audio/audio_sdl.cpp \ $(srcdir)/src/core/about_dialog.cpp \ @@ -164,6 +166,7 @@ lmms_SOURCES = \ $(srcdir)/src/widgets/nstate_button.cpp \ $(srcdir)/src/widgets/pixmap_button.cpp \ $(srcdir)/src/widgets/project_notes.cpp \ + $(srcdir)/src/widgets/qxembed.cpp \ $(srcdir)/src/widgets/rename_dialog.cpp \ $(srcdir)/src/widgets/side_bar_widget.cpp \ $(srcdir)/src/widgets/tab_bar.cpp \ @@ -269,9 +272,12 @@ lmms_SOURCES = \ $(srcdir)/include/string_pair_drag.h \ $(srcdir)/include/ladspa_manager.h \ $(srcdir)/include/midi_tab_widget.h \ + $(srcdir)/include/audio_port.h \ + $(srcdir)/include/qxembed.h \ $(srcdir)/include/midi_alsa_seq.h + EXTRA_DIST = $(lmms_EMBEDDED_RESOURCES) @@ -305,10 +311,6 @@ if HAVE_LIBSF LIB_SF_LDADD = -lsndfile endif -if HAVE_LIBFST -LIB_FST_LDADD = -lfst -endif - lmms_LDADD = $(QT_LDADD) $(LIB_SDL_LDADD) $(LIB_ASOUND_LDADD) $(LIB_JACK_LDADD) $(LIB_SDL_SOUND_LDADD) $(LIB_VORBIS_LDADD) $(LIB_SRC_LDADD) $(LIB_SF_LDADD) $(LIB_FST_LDADD) -ldl lmms_LDFLAGS = -rdynamic -rpath $(pkglibdir) diff --git a/TODO b/TODO index 678f902c08..a4dacda1e8 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +- fix audio/midi-settings stuff/translation - check ladspa-header - arpeggio: send midi-out-events via channel-track - tooltips for controls in MIDI-tab diff --git a/acinclude.m4 b/acinclude.m4 index 051df50520..604d5f4d68 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -264,3 +264,13 @@ AC_SUBST(QT_GUILINK) AC_SUBST(QASSISTANTCLIENT_LDADD) ]) + + +dnl **** Link C code with an assembly file **** +dnl +dnl Usage: WINE_TRY_ASM_LINK(asm-code,includes,function,[action-if-found,[action-if-not-found]]) +dnl +AC_DEFUN([WINE_TRY_ASM_LINK], +[AC_TRY_LINK([void ac_asm(void) { asm([$1]); } +[$2]],[$3],[$4],[$5])]) + diff --git a/configure.in b/configure.in index faefd28dd4..b2931a6dd3 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.1-cvs20051107, tobydox/at/users.sourceforge.net) -AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051107) +AC_INIT(lmms, 0.1.1-cvs20051129, tobydox/at/users.sourceforge.net) +AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051129) AM_CONFIG_HEADER(config.h) @@ -22,7 +22,7 @@ gw_CHECK_QT # checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS([fcntl.h memory.h string.h sys/ioctl.h unistd.h stdlib.h dlfcn.h ladspa.h]) +AC_CHECK_HEADERS([fcntl.h memory.h string.h sys/ioctl.h unistd.h stdlib.h dlfcn.h ladspa.h pthread.h sys/ipc.h sys/shm.h sys/time.h sys/select.h sys/types.h stdarg.h]) # checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -32,6 +32,7 @@ AC_HEADER_TIME AC_STRUCT_TM AC_C_VOLATILE AC_C_BIGENDIAN +AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t, long long]) # checks for library functions. AC_FUNC_ALLOCA @@ -39,7 +40,8 @@ AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_TYPE_SIGNAL -AC_CHECK_FUNCS([usleep]) +AC_CHECK_FUNCS([usleep pipe sprintf]) + # search for include-path of SDL (just for supporting the FreeBSD-guys.... ;-) @@ -60,6 +62,8 @@ AH_TEMPLATE(SDL_SDL_SOUND_H, [Define to location of SDL_sound.h]) OLD_LIBS="$LIBS" LIBS="$LIBS -lpthread" +AC_CHECK_FUNCS([pthread_getattr_np]) + # check for SDL-lib AC_ARG_WITH(sdl, AS_HELP_STRING([--without-sdl], @@ -154,30 +158,25 @@ fi AM_CONDITIONAL(HAVE_LIBJACK, test ! -z "$HAVE_JACK_JACK_H") -# check for VST-backends (currently only libfst is supported) +# check for proper wine-installation and existing steinberg headers AC_ARG_WITH(vst, - AS_HELP_STRING([--without-vst], - [disable support for VST-plugin-hosting]), , - [ with_vst=yes ]) + AS_HELP_STRING([--with-vst], + [enable support for VST-plugin-hosting]), [ with_vst=yes ], [ with_vst=no ]) AH_TEMPLATE(HAVE_VST_AEFFECTX_H, [Define to 1 if you have the header file.]) -AH_TEMPLATE(HAVE_FST_H, [Define to 1 if you have the header file.]) if test "x$with_vst" = "xyes" ; then AC_CHECK_HEADER(vst/aeffectx.h, HAVE_VST_AEFFECTX_H="true") - AC_CHECK_HEADER(fst.h, HAVE_FST_H="true") - AC_CHECK_LIB([fst], [fst_init], HAVE_LIBFST="true", HAVE_FST_H="") -fi -if test ! -z "$HAVE_VST_AEFFECTX_H" ; then - AC_DEFINE(HAVE_VST_AEFFECTX_H) - if test ! -z "$HAVE_FST_H" ; then - AC_DEFINE(HAVE_FST_H) - FST_OK_BUT_VST_HEADERS_MISSING="" - else - FST_OK_BUT_VST_HEADERS_MISSING="true" + AC_CHECK_PROG(WINEGCC, winegcc, /usr/bin/winegcc,,/usr/bin) + AC_CHECK_LIB([wine], [wine_init]) + if test ! -z "$WINEGCC" ; then + if test ! -z "$HAVE_VST_AEFFECTX_H" ; then + WINE_OK_BUT_VST_INCOMPLETE="" + AC_DEFINE(HAVE_VST_AEFFECTX_H) + else + WINE_OK_BUT_VST_INCOMPLETE="true" + fi fi -else - HAVE_FST_H="" fi -AM_CONDITIONAL(HAVE_LIBFST, test ! -z "$HAVE_FST_H") +AM_CONDITIONAL(VST_SUPPORT, test ! -z "$WINEGCC") # check for vorbis-lib @@ -567,49 +566,59 @@ else fi - -if test ! -z "$FST_OK_BUT_VST_HEADERS_MISSING" ; then +if test "x$with_vst" = "xno" ; then echo " ========================" - echo " === LMMS - WARNING =======================================================" + echo " === LMMS - INFORMATION ===================================================" echo " ========================" echo " =" - echo " = You seem to have a proper libfst-installation, but the header-files" - echo " = (AEffect.h and aeffectx.h) from Steinberg-SDK are missing or not present" - echo " = in /usr/include/vst. We cannot distribute them as they're licensed under" - echo " = a non-GPL-compatible license, so you'll have to download them at" + echo " = If you want VST-support within LMMS, please pass" echo " =" - echo " = ftp://ext2asio:sdk1ext@ftp.pinnaclesys.com/SDK" + echo " = --with-vst" echo " =" - echo " = and put the mentioned files into /usr/include." - echo " = Otherwise (now!) configure will disable LMMS's support for built-in VST-" - echo " = plugin-usage. If you do not intend to use VST-plugins with LMMS you can " - echo " = ignore this warning." - echo " = Consider installing the missing packages for using the full power of LMMS." + echo " = to configure, since it is disabled per default!" echo " =" - with_warnings="true" else - if test ! -z "$HAVE_FST_H" ; then - PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD\n\t\* libfst for hosting VST-plugins" - else + + if test ! -z "$WINE_OK_BUT_VST_INCOMPLETE" ; then echo " ========================" echo " === LMMS - WARNING =======================================================" echo " ========================" echo " =" - echo " = You don't seem to have installed libfst, which is neccessary for building" - echo " = LMMS with support for built-in VST-plugin. Furthermore LMMS needs" - echo " = header-files (AEffect.h and aeffectx.h) from Steinberg-SDK, which are" - echo " = likely to be installed by libfst, so after having coped with libfst-" - echo " = installation (which is a mess... ;-), everything should be alright." - echo " = If you do not intend to use VST-plugins with LMMS you can ignore this " - echo " = warning." + echo " = You seem to have a proper WINE-installation, but the header-files" + echo " = (AEffect.h and aeffectx.h) from Steinberg-VST-SDK are missing or not present" + echo " = in /usr/include/vst. We cannot distribute them as they're licensed under" + echo " = a GPL-incompatible license, so you'll have to download them at" + echo " =" + echo " = ftp://ext2asio:sdk1ext@ftp.pinnaclesys.com/SDK" + echo " =" + echo " = and put the mentioned files into /usr/include/vst." + echo " = Otherwise (now!) configure will disable LMMS's support for built-in VST-" + echo " = plugin-usage. If you do not intend to use VST-plugins with LMMS you can " + echo " = ignore this warning." echo " = Consider installing the missing packages for using the full power of LMMS." echo " =" with_warnings="true" + else + if test ! -z "$HAVE_VST_AEFFECTX_H" ; then + PLUGINS_TO_BUILD="$PLUGINS_TO_BUILD\n\t\* it's own VST-server for hosting VST-plugins" + else + echo " ========================" + echo " === LMMS - WARNING =======================================================" + echo " ========================" + echo " =" + echo " = You don't seem to have installed WINE or it's development-packages (headers," + echo " = (winegcc etc.) which is neccessary for building LMMS with built-in" + echo " = VST-support." + echo " = If you do not intend to use VST-plugins with LMMS you can ignore this " + echo " = warning." + echo " = Consider installing the missing packages for using the full power of LMMS." + echo " =" + with_warnings="true" + fi fi fi - echo echo echo "LMMS will be able to use $PLUGINS_TO_BUILD" | sed -e "s/\\\n/\n/g" | sed -e "s/\\\t/\t/g" | sed -e "s/\\\\\*/\*/g" diff --git a/include/about_dialog.h b/include/about_dialog.h index ccef478ef1..90f2de7beb 100644 --- a/include/about_dialog.h +++ b/include/about_dialog.h @@ -1,8 +1,9 @@ /* * about_dialog.h - declaration of class aboutDialog * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/arp_and_chords_tab_widget.h b/include/arp_and_chords_tab_widget.h index 59daba0e48..317c2eb121 100644 --- a/include/arp_and_chords_tab_widget.h +++ b/include/arp_and_chords_tab_widget.h @@ -2,8 +2,9 @@ * arp_and_chords_tab_widget.h - declaration of class arpAndChordWidget which * provides code for using arpeggio and chords * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_alsa.h b/include/audio_alsa.h index 949a9b1ac6..e483de3240 100644 --- a/include/audio_alsa.h +++ b/include/audio_alsa.h @@ -1,8 +1,9 @@ /* * audio_alsa.h - device-class that implements ALSA-PCM-output * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_device.h b/include/audio_device.h index 96d945c8e8..fe2457fa61 100644 --- a/include/audio_device.h +++ b/include/audio_device.h @@ -1,8 +1,9 @@ /* * audio_device.h - base-class for audio-devices, used by LMMS-mixer * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -29,10 +30,12 @@ #ifdef QT4 +#include #include #else +#include #include #endif @@ -50,6 +53,11 @@ #include "tab_widget.h" + +class audioPort; + + + class audioDevice { public: @@ -66,10 +74,22 @@ public: m_devMutex.unlock(); } + // called by mixer for writing final output-buffer with given sample- + // rate and master-gain void FASTCALL writeBuffer( surroundSampleFrame * _ab, Uint32 _frames, Uint32 _src_sample_rate, float _master_gain ); + + // if audio-driver supports ports, classes inherting audioPort + // (e.g. channel-tracks) can register themselves for making + // audio-driver able to collect their individual output and provide + // them at a specific port - currently only supported by JACK + virtual void registerPort( audioPort * _port ); + virtual void unregisterPort( audioPort * _port ); + virtual void renamePort( audioPort * _port, const QString & _name ); + + inline Uint32 sampleRate( void ) const { return( m_sampleRate ); @@ -102,6 +122,7 @@ public: protected: + // to be implemented by audio-driver - last step in a mixer period virtual void FASTCALL writeBufferToDev( surroundSampleFrame * _ab, Uint32 _frames, float _master_gain ) = 0; @@ -121,6 +142,7 @@ protected: void FASTCALL resample( surroundSampleFrame * _src, Uint32 _frames, surroundSampleFrame * _dst, Uint32 _src_sr, Uint32 _dst_sr ); + inline void setSampleRate( Uint32 _new_sr ) { m_sampleRate = _new_sr; diff --git a/include/audio_dummy.h b/include/audio_dummy.h index 97d4033fb5..349e8abf1a 100644 --- a/include/audio_dummy.h +++ b/include/audio_dummy.h @@ -1,8 +1,9 @@ /* * audio_dummy.h - dummy-audio-device * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_file_device.h b/include/audio_file_device.h index 065d4e6854..dd5c7683d3 100644 --- a/include/audio_file_device.h +++ b/include/audio_file_device.h @@ -2,8 +2,9 @@ * audio_file_device.h - base-class for audio-device-classes which write * their output into a file * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_file_ogg.h b/include/audio_file_ogg.h index 1c409377c2..43c551711d 100644 --- a/include/audio_file_ogg.h +++ b/include/audio_file_ogg.h @@ -2,8 +2,9 @@ * audio_file_ogg.h - Audio-device which encodes wave-stream and writes it * into an OGG-file. This is used for song-export. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_file_wave.h b/include/audio_file_wave.h index a2f8fb422c..d05177736f 100644 --- a/include/audio_file_wave.h +++ b/include/audio_file_wave.h @@ -2,8 +2,9 @@ * audio_file_wave.h - Audio-device which encodes wave-stream and writes it * into an WAVE-file. This is used for song-export. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_jack.h b/include/audio_jack.h index 31f738d512..b402d7bf24 100644 --- a/include/audio_jack.h +++ b/include/audio_jack.h @@ -1,8 +1,9 @@ /* * audio_jack.h - support for JACK-transport * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -93,10 +94,13 @@ private: Uint32 _frames, float _master_gain ); - void clearBuffer( void ); + virtual void registerPort( audioPort * _port ); + virtual void unregisterPort( audioPort * _port ); + virtual void renamePort( audioPort * _port, const QString & _name ); static int processCallback( jack_nframes_t _nframes, void * _udata ); static int bufSizeCallback( jack_nframes_t _nframes, void * _udata ); + static void shutdownCallback( void * _udata ); jack_client_t * m_client; diff --git a/include/audio_oss.h b/include/audio_oss.h index 8d7666a5cf..76ffe41041 100644 --- a/include/audio_oss.h +++ b/include/audio_oss.h @@ -1,8 +1,9 @@ /* * audio_oss.h - device-class that implements OSS-PCM-output * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_port.h b/include/audio_port.h new file mode 100644 index 0000000000..1a995ca3c4 --- /dev/null +++ b/include/audio_port.h @@ -0,0 +1,100 @@ +/* + * audio_port.h - base-class for objects providing sound at a port + * + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + + +#ifndef _AUDIO_PORT_H +#define _AUDIO_PORT_H + +#include "qt3support.h" + +#ifdef QT4 + +#include + +#else + +#include + +#endif + + +#include "mixer.h" +#include "effect_board.h" + + +class audioPort +{ +public: + audioPort( const QString & _name ); + ~audioPort(); + + inline surroundSampleFrame * firstBuffer( void ) + { + return( m_firstBuffer ); + } + inline surroundSampleFrame * secondBuffer( void ) + { + return( m_secondBuffer ); + } + + void nextPeriod( void ); + + + // indicate whether JACK & Co should provide output-buffer at ext. port + inline bool extOutputEnabled( void ) const + { + return( m_extOutputEnabled ); + } + void FASTCALL setExtOutputEnabled( bool _enabled ); + + + // next effect-channel after this audio-port + // (-1 = none 0 = master) + inline fxChnl nextFxChannel( void ) const + { + return( m_nextFxChannel ); + } + void setNextFxChannel( fxChnl _chnl ) + { + m_nextFxChannel = _chnl; + } + + void setName( const QString & _new_name ); + + enum bufferUsages + { + NONE, FIRST, BOTH + } m_bufferUsage; + + +private: + surroundSampleFrame * m_firstBuffer; + surroundSampleFrame * m_secondBuffer; + bool m_extOutputEnabled; + fxChnl m_nextFxChannel; + +} ; + + +#endif diff --git a/include/audio_sample_recorder.h b/include/audio_sample_recorder.h index 40a08c566b..809b83dff4 100644 --- a/include/audio_sample_recorder.h +++ b/include/audio_sample_recorder.h @@ -3,8 +3,9 @@ * surround-audio-buffers into RAM, maybe later * also harddisk * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/audio_sdl.h b/include/audio_sdl.h index ec7b7956dc..f4654a6f3d 100644 --- a/include/audio_sdl.h +++ b/include/audio_sdl.h @@ -1,8 +1,9 @@ /* * audio_sdl.h - device-class that performs PCM-output via SDL * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/basic_filters.h b/include/basic_filters.h index d0ea55603b..b115eb7a24 100644 --- a/include/basic_filters.h +++ b/include/basic_filters.h @@ -4,8 +4,9 @@ * original file by ??? * modified and enhanced by Tobias Doerffel, 2004 * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/bb_editor.h b/include/bb_editor.h index 266481ca15..89333c26bd 100644 --- a/include/bb_editor.h +++ b/include/bb_editor.h @@ -1,8 +1,9 @@ /* * bb_editor.h - declaration of class bbEditor, a basic-component of LMMS * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/bb_track.h b/include/bb_track.h index 3380525b9c..bd70752709 100644 --- a/include/bb_track.h +++ b/include/bb_track.h @@ -2,8 +2,9 @@ * bb_track.h - class bbTrack, a wrapper for using bbEditor * (which is a singleton-class) as track * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/buffer_allocator.h b/include/buffer_allocator.h index f024495035..5da4b6b50c 100644 --- a/include/buffer_allocator.h +++ b/include/buffer_allocator.h @@ -2,8 +2,9 @@ * buffer_allocator.h - namespace bufferAllocator providing routines for own * optimized memory-management for audio-buffers * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/clipboard.h b/include/clipboard.h index 0eb443642a..a288c30ad7 100644 --- a/include/clipboard.h +++ b/include/clipboard.h @@ -1,8 +1,9 @@ /* * clipboard.h - the clipboard for patterns, notes etc. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/config_mgr.h b/include/config_mgr.h index feb577b465..c3ec926663 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -1,8 +1,9 @@ /* * config_mgr.h - class configManager, a class for managing LMMS-configuration * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/debug.h b/include/debug.h index 413b026b16..6b3d5e2c12 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,8 +1,9 @@ /* * debug.h - header file to be included for debugging purposes * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/dummy_instrument.h b/include/dummy_instrument.h index 7896b3bc0c..8c87e33689 100644 --- a/include/dummy_instrument.h +++ b/include/dummy_instrument.h @@ -2,8 +2,9 @@ * dummy_instrument.h - instrument used as fallback if an instrument couldn't * be loaded * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/dummy_plugin.h b/include/dummy_plugin.h index 16b46693d8..819bee932c 100644 --- a/include/dummy_plugin.h +++ b/include/dummy_plugin.h @@ -2,8 +2,9 @@ * dummy_plugin.h - empty plugin which is used as fallback if a plugin wasn't * found * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/effect_board.h b/include/effect_board.h index c386cd0ab4..f5262554d9 100644 --- a/include/effect_board.h +++ b/include/effect_board.h @@ -1,8 +1,9 @@ /* * effect_board.h - stuff for effect-board * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -24,8 +25,12 @@ #ifndef _EFFECT_BOARD_H #define _EFFECT_BOARD_H + const int MIN_EFFECT_CHANNEL = 0; const int MAX_EFFECT_CHANNEL = 63; -const int DEFAULT_EFFECT_CHANNEL = (MIN_EFFECT_CHANNEL); +const int DEFAULT_EFFECT_CHANNEL = MIN_EFFECT_CHANNEL; + +typedef Sint8 fxChnl; + #endif diff --git a/include/embed.h b/include/embed.h index c0510ce527..f9f4088012 100644 --- a/include/embed.h +++ b/include/embed.h @@ -1,8 +1,9 @@ /* * embed.h - misc. stuff for using embedded data (resources linked into binary) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/endian_handling.h b/include/endian_handling.h index 0a9a539fbf..e7ce889e52 100644 --- a/include/endian_handling.h +++ b/include/endian_handling.h @@ -1,8 +1,9 @@ /* * endian.h - handle endianess-problems * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/envelope_and_lfo_widget.h b/include/envelope_and_lfo_widget.h index 89e69cc39e..ece8c91399 100644 --- a/include/envelope_and_lfo_widget.h +++ b/include/envelope_and_lfo_widget.h @@ -3,8 +3,9 @@ * is used by envelope/lfo/filter-tab of * channel-window * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/envelope_tab_widget.h b/include/envelope_tab_widget.h index edafefd2a1..a03dde991e 100644 --- a/include/envelope_tab_widget.h +++ b/include/envelope_tab_widget.h @@ -3,8 +3,9 @@ * provides UI- and DSP-code for using envelopes, LFOs * and a filter * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/export.h b/include/export.h index 2911654d42..943b720e59 100644 --- a/include/export.h +++ b/include/export.h @@ -1,8 +1,9 @@ /* * export.h - header which is needed for song-export * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/export_project_dialog.h b/include/export_project_dialog.h index bf420a81da..5bb5586628 100644 --- a/include/export_project_dialog.h +++ b/include/export_project_dialog.h @@ -2,8 +2,9 @@ * export_project_dialog.h - declaration of class exportProjectDialog which is * responsible for exporting project * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/file_browser.h b/include/file_browser.h index 115da08283..384e8a1ceb 100644 --- a/include/file_browser.h +++ b/include/file_browser.h @@ -1,8 +1,9 @@ /* * file_browser.h - include file for fileBrowser * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/group_box.h b/include/group_box.h index c05e9c4043..e033e8a582 100644 --- a/include/group_box.h +++ b/include/group_box.h @@ -1,8 +1,9 @@ /* * group_box.h - LMMS-groupbox * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/gui_templates.h b/include/gui_templates.h index c7fdc1122d..144e988f88 100644 --- a/include/gui_templates.h +++ b/include/gui_templates.h @@ -1,8 +1,9 @@ /* * gui_templates.h - GUI-specific templates * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/instrument.h b/include/instrument.h index 38cbc4727d..5813dc8140 100644 --- a/include/instrument.h +++ b/include/instrument.h @@ -2,8 +2,9 @@ * instrument.h - declaration of class instrument, which provides a * standard interface for all instrument plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/instrument_play_handle.h b/include/instrument_play_handle.h index b694f62833..3c9fbf7502 100644 --- a/include/instrument_play_handle.h +++ b/include/instrument_play_handle.h @@ -1,8 +1,9 @@ /* * instrument_play_handle.h - play-handle for playing an instrument * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/interpolation.h b/include/interpolation.h index 012260ea9f..5e7b5cfedc 100644 --- a/include/interpolation.h +++ b/include/interpolation.h @@ -1,8 +1,9 @@ /* * interpolation.h - fast implementations of several interpolation-algorithms * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/knob.h b/include/knob.h index 15271933bd..a3f6216c13 100644 --- a/include/knob.h +++ b/include/knob.h @@ -4,8 +4,9 @@ * This file is based on the knob-widget of the Qwt Widget Library by * Josef Wilgen * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/ladspa_manager.h b/include/ladspa_manager.h index 12c917bc5c..002fe1c6da 100644 --- a/include/ladspa_manager.h +++ b/include/ladspa_manager.h @@ -3,9 +3,10 @@ * a class to manage loading and instantiation * of ladspa plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Danny McRae + * Copyright (c) 2005 Danny McRae * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either diff --git a/include/lcd_spinbox.h b/include/lcd_spinbox.h index fda06089ff..e8dd0feb36 100644 --- a/include/lcd_spinbox.h +++ b/include/lcd_spinbox.h @@ -1,8 +1,9 @@ /* * lcd_spinbox.h - class lcdSpinBox, an improved QLCDNumber * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/led_checkbox.h b/include/led_checkbox.h index 90fed3fc79..5e648715b0 100644 --- a/include/led_checkbox.h +++ b/include/led_checkbox.h @@ -1,8 +1,9 @@ /* * led_checkbox.h - class ledCheckBox, an improved QCheckBox * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi.h b/include/midi.h index 844dfdd31b..6c7ef0e525 100644 --- a/include/midi.h +++ b/include/midi.h @@ -1,8 +1,9 @@ /* * midi.h - constants, structs etc. concerning MIDI * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -99,7 +100,7 @@ struct midiEvent union { Uint16 m_param[2]; // first/second parameter (key/velocity) - int m_sysExDataLen; // len of m_sysExData + Uint32 m_sysExDataLen; // len of m_sysExData } m_data; const char * m_sysExData; diff --git a/include/midi_alsa_raw.h b/include/midi_alsa_raw.h index 7d3a24490e..3f00418086 100644 --- a/include/midi_alsa_raw.h +++ b/include/midi_alsa_raw.h @@ -1,8 +1,9 @@ /* * midi_alsa_raw.h - midi-client for RawMIDI via ALSA * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_alsa_seq.h b/include/midi_alsa_seq.h index 9a19fa8d8e..1b3aeb9943 100644 --- a/include/midi_alsa_seq.h +++ b/include/midi_alsa_seq.h @@ -1,8 +1,9 @@ /* * midi_alsa_seq.h - ALSA-sequencer-client * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_client.h b/include/midi_client.h index 735ae46f5e..7c7b559620 100644 --- a/include/midi_client.h +++ b/include/midi_client.h @@ -1,8 +1,9 @@ /* * midi_client.h - base-class for MIDI-clients like ALSA-sequencer-client * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_dummy.h b/include/midi_dummy.h index 1de43be1da..5eb38e42cd 100644 --- a/include/midi_dummy.h +++ b/include/midi_dummy.h @@ -1,8 +1,9 @@ /* * midi_dummy.h - dummy MIDI-driver * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_event_processor.h b/include/midi_event_processor.h index a0d93d231d..7ca709add9 100644 --- a/include/midi_event_processor.h +++ b/include/midi_event_processor.h @@ -1,8 +1,9 @@ /* * midi_event_processor.h - base-class for midi-processing classes * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_mapper.h b/include/midi_mapper.h index 5608c9163e..de66fbbd82 100644 --- a/include/midi_mapper.h +++ b/include/midi_mapper.h @@ -1,8 +1,9 @@ /* * midi_mapper.h - MIDI-mapper for any midiDevice * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_oss.h b/include/midi_oss.h index 9d30470847..7b90441ae1 100644 --- a/include/midi_oss.h +++ b/include/midi_oss.h @@ -1,8 +1,9 @@ /* * midi_oss.h - OSS-raw-midi-client * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_port.h b/include/midi_port.h index 4ed6825912..a936194b6f 100644 --- a/include/midi_port.h +++ b/include/midi_port.h @@ -2,8 +2,9 @@ * midi_port.h - abstraction of MIDI-ports which are part of LMMS's MIDI- * sequencing system * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_tab_widget.h b/include/midi_tab_widget.h index 99ede0f171..655932118a 100644 --- a/include/midi_tab_widget.h +++ b/include/midi_tab_widget.h @@ -2,8 +2,9 @@ * midi_tab_widget.h - tab-widget in channel-track-window for setting up * MIDI-related stuff * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/midi_time.h b/include/midi_time.h index 2ea8d5a42a..c47336ede5 100644 --- a/include/midi_time.h +++ b/include/midi_time.h @@ -2,8 +2,9 @@ * midi_time.h - declaration of class midiTime which provides data-type for * position- and length-variables * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/mixer.h b/include/mixer.h index 8eb2105482..7273ed711c 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -1,8 +1,9 @@ /* * mixer.h - audio-device-independent mixer for LMMS * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -52,20 +53,18 @@ #include "panning.h" #include "note.h" #include "play_handle.h" +#include "effect_board.h" class audioDevice; class midiClient; class lmmsMainWin; class plugin; +class audioPort; const int DEFAULT_BUFFER_SIZE = 512; -const Uint16 MAX_SAMPLE_PACKETS = 256; // how many parallel audio-samples- - // buffers shall be maximal exist and - // mixed together? - const Uint8 DEFAULT_CHANNELS = 2; const Uint8 SURROUND_CHANNELS = @@ -79,7 +78,7 @@ const Uint8 QUALITY_LEVELS = 2; const Uint32 DEFAULT_QUALITY_LEVEL = 0; const Uint32 HIGH_QUALITY_LEVEL = DEFAULT_QUALITY_LEVEL+1; extern Uint32 SAMPLE_RATES[QUALITY_LEVELS]; -const Uint32 DEFAULT_SAMPLE_RATE = 44100;//SAMPLE_RATES[DEFAULT_QUALITY_LEVEL]; +const Uint32 DEFAULT_SAMPLE_RATE = 44100; typedef sampleType sampleFrame[DEFAULT_CHANNELS]; @@ -123,9 +122,10 @@ public: } - void FASTCALL addBuffer( sampleFrame * _buf, Uint32 _frames, + void FASTCALL bufferToPort( sampleFrame * _buf, Uint32 _frames, Uint32 _framesAhead, - volumeVector & _volumeVector ); + volumeVector & _volumeVector, + audioPort * _port ); inline Uint32 framesPerAudioBuffer( void ) const { return( m_framesPerAudioBuffer ); @@ -151,8 +151,31 @@ public: void FASTCALL setAudioDevice( audioDevice * _dev, bool _hq ); void restoreAudioDevice( void ); + inline audioDevice * audioDev( void ) + { + return( m_audioDev ); + } + // audio-port-stuff + inline void addAudioPort( audioPort * _port ) + { + pause(); + m_audioPorts.push_back( _port ); + play(); + } + + inline void removeAudioPort( audioPort * _port ) + { + vvector::iterator it = qFind( m_audioPorts.begin(), + m_audioPorts.end(), + _port ); + if( it != m_audioPorts.end() ) + { + m_audioPorts.erase( it ); + } + } + // MIDI-client-stuff inline const QString & midiClientName( void ) const { @@ -246,22 +269,6 @@ signals: private: - struct samplePacket - { - surroundSampleFrame * m_buffer; // actual buffer for - // wave-data - Uint32 m_frames; - Uint32 m_framesDone; - Uint32 m_framesAhead; // number of frames, the buffer - // should be mixed ahead - volume m_vol; - panning m_pan; - enum samplePacketStates - { - READY, FILLING, UNUSED - } m_state; - } ; - static mixer * s_instanceOfMe; @@ -272,40 +279,29 @@ private: // we don't allow to create mixer by using copy-ctor - mixer( const mixer & ) : -#ifndef QT4 - QObject(), -#endif - QThread(), - m_curBuf( m_buffer1 ), - m_nextBuf( m_buffer2 ) + mixer( const mixer & ) { } virtual void run( void ); - void FASTCALL mixSamplePacket( samplePacket * _sp ); - - audioDevice * tryAudioDevices( void ); midiClient * tryMIDIClients( void ); + void processBuffer( surroundSampleFrame * _buf, fxChnl _fx_chnl ); - sampleFrame * m_silence; +/* sampleFrame * m_silence; #ifndef DISABLE_SURROUND surroundSampleFrame * m_surroundSilence;// cool, silence in surround ;-) -#endif +#endif*/ - samplePacket m_samplePackets[MAX_SAMPLE_PACKETS]; + vvector m_audioPorts; Uint32 m_framesPerAudioBuffer; - surroundSampleFrame * m_buffer1; - surroundSampleFrame * m_buffer2; - surroundSampleFrame * m_curBuf; surroundSampleFrame * m_nextBuf; diff --git a/include/mmp.h b/include/mmp.h index fcd23979c2..6ce08a14dc 100644 --- a/include/mmp.h +++ b/include/mmp.h @@ -1,8 +1,9 @@ /* * mmp.h - class for reading and writing multimedia-project-files * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/name_label.h b/include/name_label.h index 042728a47d..d7c6517922 100644 --- a/include/name_label.h +++ b/include/name_label.h @@ -2,8 +2,9 @@ * name_label.h - class nameLabel, a label which is renamable by * double-clicking it * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/note.h b/include/note.h index 1e6bfdf468..1ef6bab8c0 100644 --- a/include/note.h +++ b/include/note.h @@ -2,8 +2,9 @@ * note.h - declaration of class note which contains all informations about a * note + definitions of several constants and enums * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/note_play_handle.h b/include/note_play_handle.h index 6c4c060306..4ee5e46c41 100644 --- a/include/note_play_handle.h +++ b/include/note_play_handle.h @@ -2,8 +2,9 @@ * note_play_handle.h - declaration of class notePlayHandle which is needed * by LMMS-Play-Engine * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/nstate_button.h b/include/nstate_button.h index 295ab9df35..809489c9e3 100644 --- a/include/nstate_button.h +++ b/include/nstate_button.h @@ -1,8 +1,9 @@ /* * nstate_button.h - declaration of class nStateButton * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/oscillator.h b/include/oscillator.h index 612bf6b0ed..ebd72ce6d1 100644 --- a/include/oscillator.h +++ b/include/oscillator.h @@ -1,8 +1,9 @@ /* * oscillator.h - header-file for oscillator.cpp, a powerful oscillator-class * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/panning.h b/include/panning.h index aa18a7595e..09799fbd1d 100644 --- a/include/panning.h +++ b/include/panning.h @@ -2,8 +2,9 @@ * panning.h - declaration of some constants and types, concerning the * panning of a note * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/pattern.h b/include/pattern.h index 022f453e98..046fb06526 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -2,8 +2,9 @@ * pattern.h - declaration of class pattern, which contains all informations * about a pattern * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/piano_roll.h b/include/piano_roll.h index 94fe41c99d..7cd63f6f94 100644 --- a/include/piano_roll.h +++ b/include/piano_roll.h @@ -2,8 +2,9 @@ * piano_roll.h - declaration of class pianoRoll which is a window where you * can set and edit notes in an easy way * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/piano_widget.h b/include/piano_widget.h index 700f7e7298..b693769440 100644 --- a/include/piano_widget.h +++ b/include/piano_widget.h @@ -2,8 +2,9 @@ * piano_widget.h - declaration of class pianoWidget, a widget which provides * an interactive piano/keyboard-widget * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/pixmap_button.h b/include/pixmap_button.h index 10bce4398f..cd9e13fac1 100644 --- a/include/pixmap_button.h +++ b/include/pixmap_button.h @@ -1,8 +1,9 @@ /* * pixmap_button.h - declaration of class pixmapButton * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/play_handle.h b/include/play_handle.h index ba8b6ed3c1..99ac0e907e 100644 --- a/include/play_handle.h +++ b/include/play_handle.h @@ -1,9 +1,10 @@ /* * play_handle.h - base-class playHandle which is needed by - * LMMS-Play-Engine + * LMMS-Player-Engine * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/plugin.h b/include/plugin.h index 116e7392d5..34ca1f06e9 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -1,8 +1,9 @@ /* * plugin.h - class plugin, the base-class and generic interface for all plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/plugin_browser.h b/include/plugin_browser.h index fcb3c7be6a..48eb17bd86 100644 --- a/include/plugin_browser.h +++ b/include/plugin_browser.h @@ -1,8 +1,9 @@ /* * plugin_browser.h - include file for pluginBrowser * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/preset_preview_play_handle.h b/include/preset_preview_play_handle.h index 9e7b1b3904..117fa15a15 100644 --- a/include/preset_preview_play_handle.h +++ b/include/preset_preview_play_handle.h @@ -2,8 +2,9 @@ * preset_preview_play_handle.h - play-handle for playing a short preview-sound * of a preset * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/project_notes.h b/include/project_notes.h index a6a5e96f14..59d9fcc35d 100644 --- a/include/project_notes.h +++ b/include/project_notes.h @@ -1,8 +1,9 @@ /* * project_notes.h - header for project-notes-editor * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/qt3support.h b/include/qt3support.h index b2567fa9fa..de8898af7f 100644 --- a/include/qt3support.h +++ b/include/qt3support.h @@ -1,8 +1,9 @@ /* * qt3support.h - layer for supporting Qt3 * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/qxembed.h b/include/qxembed.h new file mode 100644 index 0000000000..79259dc745 --- /dev/null +++ b/include/qxembed.h @@ -0,0 +1,234 @@ +/**************************************************************************** + Definition of QXEmbed class + + Copyright (C) 1999-2000 Troll Tech AS + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*****************************************************************************/ + +#ifndef QXEMBED_H +#define QXEMBED_H + +#include +/*#include */ + + +#ifdef Q_WS_X11 + +class QXEmbedData; + +/** + * A QXEmbed widget serves as an embedder that can manage one single embedded + * X-window. These so-called client windows can be arbitrary Qt or non Qt + * applications. + * + * There are two different ways of using QXEmbed, + * from the client side or from the embedder's side. + * + * Embedding from the client's side requires that the client knows the + * window identifier of the respective embedder widget. Use either + * embedClientIntoWindow() or the high-level wrapper processClientCmdline(). + * This is only possible when the client is a Qt application. + * + * When using it from the embedder's side, you must know the window + * identifier of the window that should be embedded. Simply call embed() + * with this identifier as parameter. If the client is a Qt application, + * make sure it has called QXEmbed::initialize(). Otherwise you should + * probably call setProtocol(XPLAIN) before embed(). + * + * Reimplement the change handler windowChanged() to catch embedding or + * the destruction of embedded windows. In the latter case, the + * embedder also emits a signal embeddedWindowDestroyed() for + * convenience. + * + * @short The QXEmbed widget is a graphical socket that can embed an external X-Window. +*/ +class QXEmbed : public QWidget +{ + Q_OBJECT + +public: + + /** + * + * Constructs a xembed widget. + * + * The parent, name and f arguments are passed to the QFrame + * constructor. + */ + QXEmbed( QWidget *parent=0, const char *name=0, WFlags f = 0 ); + + /** + * Destructor. Cleans up the focus if necessary. + */ + ~QXEmbed(); + + /** + * Embedded applications should call this function to make sure + * they support the XEMBED protocol. It is called automatically + * when you use embedClientIntoWindow() or + * processClientCmdline(). Clients might have to call it + * manually when you use embed(). + */ + static void initialize(); + + enum Protocol { XEMBED, XPLAIN }; + + /** + * Sets the protocol used for embedding windows. + * This function must be called before embedding a window. + * Protocol XEMBED provides maximal functionality (focus, tabs, etc) + * but requires explicit cooperation from the embedded window. + * Protocol XPLAIN provides maximal compatibility with + * embedded applications that do not support the XEMBED protocol. + * The default is XEMBED. + * + * Non KDE applications should be embedded with protocol XPLAIN. + * This does not happen automatically yet. + * You must call setProtocol() explicitly. + */ + + void setProtocol( Protocol proto ); + + /** + * Returns the protocol used for embedding the current window. + * + * @return the protocol used by QXEmbed. + */ + + Protocol protocol(); + + /** + * Embeds the window with the identifier w into this xembed widget. + * + * This function is useful if the embedder knows about the client window + * that should be embedded. Often it is vice versa: the client knows + * about its target embedder. In that case, it is not necessary to call + * embed(). Instead, the client will call the static function + * embedClientIntoWindow(). + * + * @param w the identifier of the window to embed + * @see embeddedWinId() + */ + void embed( WId w ); + + /** + * Returns the window identifier of the embedded window, or 0 if no + * window is embedded yet. + * + * @return the id of the embedded window (0 if no window is embedded) + */ + WId embeddedWinId() const; + + /** + * A function for clients that embed themselves. The widget + * client will be embedded in the window window. The application has + * to ensure that window is the handle of the window identifier of + * an QXEmbed widget. + * + * @short #processClientCmdline() + */ + static void embedClientIntoWindow( QWidget* client, WId window ); + + /** + * A utility function for clients that embed theirselves. The widget + * client will be embedded in the window that is passed as + * -embed command line argument. + * + * The function returns true on success or false if no such command line + * parameter is specified. + * + * @see embedClientIntoWindow() + */ + static bool processClientCmdline( QWidget* client, int& argc, char ** argv ); + + /** + * Sends a WM_DELETE_WINDOW message to the embedded window. This is what + * typically happens when you click on the close button of a window + * manager decoration. This should cause the embedded application to + * cleanly close the window. Signal embeddedWindowDestroyed() can be used + * to monitor the status of the embedded window. + */ + void sendDelete( void ); + + /** + * Selects what shoud be done with the embedded window when the embedding + * window is destroyed. When the argument is true, the embedded window is + * kept alive, is hidden, and receives a WM_DELETE_WINDOW message using + * sendDelete(). This is the default. Otherwise, the destruction of the + * QXEmbed object simply destroys the embedded window. + * + * @see sendDelete() + */ + void setAutoDelete( bool ); + + /** + * Returns the value of flag indicating what shoud be done with the + * embedded window when the embedding window is destroyed. + * + * @see setAutoDelete() + */ + bool autoDelete() const; + + /* Reimp */ + QSize sizeHint() const; + QSize minimumSizeHint() const; + QSizePolicy sizePolicy() const; + bool eventFilter( QObject *, QEvent * ); + bool customWhatsThis() const; + void enterWhatsThisMode(); // temporary, fix in Qt (Matthias, Mon Jul 17 15:20:55 CEST 2000 ) + virtual void reparent( QWidget * parent, WFlags f, const QPoint & p, bool showIt = false ); + +signals: + /** + * This signal is emitted when the embedded window has been lost (destroyed or reparented away) + * + * @see embeddedWinId() + */ + // KDE4 rename to embeddedWindowLost() + void embeddedWindowDestroyed(); + +protected: + bool event( QEvent * ); + void keyPressEvent( QKeyEvent * ); + void keyReleaseEvent( QKeyEvent * ); + void focusInEvent( QFocusEvent * ); + void focusOutEvent( QFocusEvent * ); + void resizeEvent(QResizeEvent *); + void showEvent( QShowEvent * ); + bool x11Event( XEvent* ); + + /** + * A change handler that indicates that the embedded window has been + * changed. The window handle can also be retrieved with + * embeddedWinId(). + * + * @param w the handle of the window that changed + */ + virtual void windowChanged( WId w ); + + bool focusNextPrevChild( bool next ); + +private: + WId window; + QXEmbedData* d; + void checkGrab(); + void sendSyntheticConfigureNotifyEvent(); +}; + + +#endif +#endif diff --git a/include/rename_dialog.h b/include/rename_dialog.h index 25d3705dbb..374f163dbc 100644 --- a/include/rename_dialog.h +++ b/include/rename_dialog.h @@ -2,8 +2,9 @@ * rename_dialog.h - declaration of class renameDialog, a simple dialog for * changing the content of a string * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/sample_buffer.h b/include/sample_buffer.h index d2a0818387..54ddd38ef2 100644 --- a/include/sample_buffer.h +++ b/include/sample_buffer.h @@ -1,8 +1,9 @@ /* * sample_buffer.h - container-class sampleBuffer * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/sample_play_handle.h b/include/sample_play_handle.h index 054817aec5..ef2aa27133 100644 --- a/include/sample_play_handle.h +++ b/include/sample_play_handle.h @@ -1,8 +1,9 @@ /* * sample_play_handle.h - play-handle for playing a sample * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -30,6 +31,7 @@ class sampleBuffer; +class audioPort; class samplePlayHandle : public playHandle @@ -60,6 +62,8 @@ private: Uint32 m_frame; + audioPort * m_audioPort; + } ; diff --git a/include/sample_track.h b/include/sample_track.h index df516832cb..7cb6c8f81a 100644 --- a/include/sample_track.h +++ b/include/sample_track.h @@ -2,8 +2,9 @@ * sample_track.h - class sampleTrack, a track which provides arrangement of * samples * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -44,6 +45,7 @@ class nameLabel; +class audioPort; class QLabel; //class sampleTCOSettingsDialog; @@ -144,6 +146,7 @@ public slots: private: nameLabel * m_trackLabel; + audioPort * m_audioPort; } ; diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 0204a9a924..e607db9d4c 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -1,8 +1,9 @@ /* * setup_dialog.h - dialog for setting up LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/side_bar.h b/include/side_bar.h index c62f5539ac..497bd14cae 100644 --- a/include/side_bar.h +++ b/include/side_bar.h @@ -1,8 +1,9 @@ /* * side_bar.h - code for side-bar in LMMS * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/side_bar_widget.h b/include/side_bar_widget.h index f286a064ad..d34baa1b30 100644 --- a/include/side_bar_widget.h +++ b/include/side_bar_widget.h @@ -1,8 +1,9 @@ /* * side_bar_widget.h - base-class for all side-bar-widgets * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/song_editor.h b/include/song_editor.h index 967c1b31c0..df62206cd3 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -2,8 +2,9 @@ * song_editor.h - declaration of class songEditor, a window where you can * setup your songs * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/spc_bg_hndl_widget.h b/include/spc_bg_hndl_widget.h index 014e966523..e7abc908cf 100644 --- a/include/spc_bg_hndl_widget.h +++ b/include/spc_bg_hndl_widget.h @@ -1,8 +1,9 @@ /* * spc_bg_hndl_widget.h - class specialBgHandlingWidget * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/string_pair_drag.h b/include/string_pair_drag.h index cb72cbd4a9..f81be17028 100644 --- a/include/string_pair_drag.h +++ b/include/string_pair_drag.h @@ -2,8 +2,9 @@ * string_pair_drag.h - class stringPairDrag which provides general support * for drag'n'drop of string-pairs * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/surround_area.h b/include/surround_area.h index 0f152d9682..974ecf42c6 100644 --- a/include/surround_area.h +++ b/include/surround_area.h @@ -3,8 +3,9 @@ * position of a channel + calculation of volume for each * speaker * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/tab_bar.h b/include/tab_bar.h index eecc16c49a..0d951184ac 100644 --- a/include/tab_bar.h +++ b/include/tab_bar.h @@ -1,8 +1,9 @@ /* * tab_bar.h - class tabBar * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/tab_button.h b/include/tab_button.h index e41403cb7c..e8213aa8e2 100644 --- a/include/tab_button.h +++ b/include/tab_button.h @@ -1,8 +1,9 @@ /* * tab_button.h - declaration of class tabButton * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/tab_widget.h b/include/tab_widget.h index 2224c6b5b2..a5301476d2 100644 --- a/include/tab_widget.h +++ b/include/tab_widget.h @@ -1,8 +1,9 @@ /* * tab_widget.h - LMMS-tabwidget * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/templates.h b/include/templates.h index 0b8cfa11cf..9b3bb69b07 100644 --- a/include/templates.h +++ b/include/templates.h @@ -1,8 +1,9 @@ /* * templates.h - miscellanous templates and algorithms * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index db0d122fd1..bc7fd632e9 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -1,10 +1,9 @@ /* * tempo_sync_knob.h - adds bpm to ms conversion for knob class * - * This derived from the knob-widget by Tobias Doerffel + * Copyright (c) 2005 Danny McRae * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Danny McRae + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/text_float.h b/include/text_float.h index 45f6416ff2..d213b10e58 100644 --- a/include/text_float.h +++ b/include/text_float.h @@ -1,8 +1,9 @@ /* * text_float.h - class textFloat, a floating text-label * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/timeline.h b/include/timeline.h index 8865ea1eb5..378ca0d491 100644 --- a/include/timeline.h +++ b/include/timeline.h @@ -1,8 +1,9 @@ /* * timeline.h - class timeLine, representing a time-line with position marker * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/tooltip.h b/include/tooltip.h index 611b59775c..d0f910f872 100644 --- a/include/tooltip.h +++ b/include/tooltip.h @@ -1,8 +1,9 @@ /* * tooltip.h - namespace toolTip, a tooltip-wrapper for LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/track.h b/include/track.h index 17c66fb58e..cc73f045ea 100644 --- a/include/track.h +++ b/include/track.h @@ -2,8 +2,9 @@ * track.h - declaration of classes concerning tracks -> neccessary for all * track-like objects (beat/bassline, sample-track...) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/track_container.h b/include/track_container.h index 1375cfaa32..f4c6424a75 100644 --- a/include/track_container.h +++ b/include/track_container.h @@ -2,8 +2,9 @@ * track_container.h - base-class for all track-containers like Song-Editor, * BB-Editor... * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/types.h b/include/types.h index 27127cccb3..93c4c8f0bf 100644 --- a/include/types.h +++ b/include/types.h @@ -1,8 +1,9 @@ /* * types.h - typedefs for common types that are used in the whole app * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/visualization_widget.h b/include/visualization_widget.h index cdd8f9d310..08b580926f 100644 --- a/include/visualization_widget.h +++ b/include/visualization_widget.h @@ -1,8 +1,9 @@ /* - * visualization_widget.h - widget for visualization of waves + * visualization_widget.h - widget for visualization of sound-data * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/include/volume.h b/include/volume.h index b6e48f38b4..e9a9284246 100644 --- a/include/volume.h +++ b/include/volume.h @@ -2,8 +2,9 @@ * volume.h - declaration of some constants and types, concerning the volume * of a note * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 0a698a26c1..e1ce8b5266 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1,4 +1,4 @@ -if HAVE_LIBFST +if VST_SUPPORT VESTIGE_SUBDIR=vestige endif diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index 8cc99c1aed..2ca1874200 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -1,8 +1,9 @@ /* * audio_file_processor.cpp - instrument for using audio-files * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/audio_file_processor/audio_file_processor.h b/plugins/audio_file_processor/audio_file_processor.h index 2ac8dbca96..574ece0971 100644 --- a/plugins/audio_file_processor/audio_file_processor.h +++ b/plugins/audio_file_processor/audio_file_processor.h @@ -2,8 +2,9 @@ * audio_file_processor.h - declaration of class audioFileProcessor * (instrument-plugin for using audio-files) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/plucked_string_synth/plucked_string_synth.cpp b/plugins/plucked_string_synth/plucked_string_synth.cpp index 758c9b517f..0d769f620a 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.cpp +++ b/plugins/plucked_string_synth/plucked_string_synth.cpp @@ -1,8 +1,9 @@ /* * plucked_string_synth.cpp - instrument which uses the Karplus-Strong-algorithm * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/plucked_string_synth/plucked_string_synth.h b/plugins/plucked_string_synth/plucked_string_synth.h index ee868dd595..62c3be0005 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.h +++ b/plugins/plucked_string_synth/plucked_string_synth.h @@ -2,8 +2,9 @@ * plucked_string_sytn.h - declaration of class pluckedStringSynth which * is a synth for plucked string-sounds * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index 9b5481fb36..46dfc7551c 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -1,8 +1,9 @@ /* * triple_oscillator.cpp - powerful instrument with three oscillators * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/triple_oscillator/triple_oscillator.h b/plugins/triple_oscillator/triple_oscillator.h index 7935b428c9..35d9c35da8 100644 --- a/plugins/triple_oscillator/triple_oscillator.h +++ b/plugins/triple_oscillator/triple_oscillator.h @@ -2,8 +2,9 @@ * triple_oscillator.h - declaration of class tripleOscillator a powerful * instrument-plugin with 3 oscillators * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/plugins/vestige/Makefile.am b/plugins/vestige/Makefile.am index d2a4cc944f..01941200b7 100644 --- a/plugins/vestige/Makefile.am +++ b/plugins/vestige/Makefile.am @@ -1,6 +1,5 @@ AUTOMAKE_OPTIONS = foreign 1.4 - INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/lib -I. @@ -22,14 +21,19 @@ EMBEDDED_RESOURCES = $(wildcard *png) EXTRA_DIST = $(EMBEDDED_RESOURCES) -CLEANFILES = $(MOC_FILES) ./embedded_resources.h +CLEANFILES = $(MOC_FILES) ./embedded_resources.h xfst.exe.so + +pkglib_LTLIBRARIES = libvestige.la + +libvestige_la_SOURCES = vestige.cpp vestige.h fstclient.cpp fstclient.h + +$(libvestige_la_SOURCES): ./embedded_resources.h - -pkglib_LTLIBRARIES= libvestige.la - -libvestige_la_SOURCES = vestige.cpp vestige.h -# libvestige_la_LIBADD = -lfst - -$(libvestige_la_SOURCES): ./embedded_resources.h +CC = winegcc +pkglib_PROGRAMS = xfst_server +xfst_server_SOURCES = fstserver.cpp fstcore.c fstserver.h communication.h +xfst_server_LDFLAGS = -mwindows -L/usr/X11R6/lib -lX11 -lpthread -o $(pkglib_PROGRAMS) +xfst_server_LINK = wineg++ +nobase_pkglib_DATA = $(pkglib_PROGRAMS).exe.so diff --git a/plugins/vestige/communication.h b/plugins/vestige/communication.h new file mode 100644 index 0000000000..3151892e43 --- /dev/null +++ b/plugins/vestige/communication.h @@ -0,0 +1,87 @@ +#ifndef _COMMUNICATION_H +#define _COMMUNICATION_H + +#include +#include +#include + + +template +inline T readValue( int _fd = 0 ) +{ + T i; + read( _fd, &i, sizeof( i ) ); + return( i ); +} + + + +template +inline void writeValue( const T & _i, int _fd = 1 ) +{ + write( _fd, &_i, sizeof( _i ) ); +} + + +enum vstRemoteCommands +{ + // client -> server + LOAD_VST_PLUGIN = 0, + CLOSE_VST_PLUGIN, + PROCESS = 10, + ENQUEUE_MIDI_EVENT = 11, + SET_SAMPLE_RATE = 20, + SET_BUFFER_SIZE, + GET_SHM_KEY_AND_SIZE, + GET_VST_VERSION = 30, + GET_NAME, + GET_VENDOR_STRING, + GET_PRODUCT_STRING, + + // server -> client + SET_SHM_KEY_AND_SIZE = 100, + SET_INPUT_COUNT, + SET_OUTPUT_COUNT, + SET_XID, + INITIALIZATION_DONE, + FAILED_LOADING_PLUGIN, + QUIT_ACK, + GET_SAMPLE_RATE = 110, + GET_BUFFER_SIZE, + GET_BPM, + SET_VST_VERSION, + SET_NAME, + SET_VENDOR_STRING, + SET_PRODUCT_STRING, + PROCESS_DONE = 120, + + DEBUG_MSG = 200, + UNDEFINED_CMD + +} ; + + + + +static inline std::string readString( int _fd = 0 ) +{ + Sint16 len = readValue( _fd ); + char * sc = new char[len]; + read( _fd, sc, len ); + std::string s( sc ); + delete[] sc; + return( s ); +} + + + + +static inline void writeString( const char * _str, int _fd = 1 ) +{ + int len = strlen( _str ) + 1; + writeValue( len, _fd ); + write( _fd, _str, len ); +} + + +#endif diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index c13a5ee06a..29ba0df847 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -1,8 +1,9 @@ /* * vestige.cpp - instrument-plugin for hosting VST-plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -31,6 +32,7 @@ #include #include #include +#include #include #else @@ -40,12 +42,12 @@ #include #include #include +#include #include #endif -#include "vestige.h" #include "channel_track.h" #include "note_play_handle.h" #include "buffer_allocator.h" @@ -55,6 +57,7 @@ #include "pixmap_button.h" #include "tooltip.h" #include "spc_bg_hndl_widget.h" +#include "vestige.h" #include "embed.cpp" @@ -79,16 +82,13 @@ plugin::descriptor vestige_plugin_descriptor = } -bool vestigeInstrument::s_initialized = FALSE; -bool vestigeInstrument::s_threadAdopted = FALSE; QPixmap * vestigeInstrument::s_artwork = NULL; vestigeInstrument::vestigeInstrument( channelTrack * _channel_track ) : instrument( _channel_track, vestige_plugin_descriptor.public_name ), specialBgHandlingWidget( PLUGIN_NAME::getIconPixmap( "artwork" ) ), - m_handle( NULL ), - m_fst( NULL ) + m_plugin( NULL ) { if( s_artwork == NULL ) { @@ -126,15 +126,18 @@ vestigeInstrument::vestigeInstrument( channelTrack * _channel_track ) : "clicking on this button, a file-open-dialog appears " "and you can select your file." ) ); - if( s_initialized == FALSE ) - { - if( fst_init( fst_signal_handler ) ) - { - // TODO: message-box - return; - } - s_initialized = TRUE; - } + m_toggleGUIButton = new QPushButton( tr( "Show/hide VST-GUI" ), this ); + m_toggleGUIButton->setGeometry( 20, 120, 128, 24 ); + connect( m_toggleGUIButton, SIGNAL( clicked() ), this, + SLOT( toggleGUI() ) ); +#ifdef QT4 + m_toggleGUIButton->setWhatsThis( +#else + QWhatsThis::add( m_toggleGUIButton, +#endif + tr( "Click here to show or hide the graphical user interface " + "(GUI) of your VST-plugin." ) ); + // now we need a play-handle which cares for calling play() instrumentPlayHandle * iph = new instrumentPlayHandle( this ); mixer::inst()->addPlayHandle( iph ); @@ -186,71 +189,36 @@ void vestigeInstrument::setParameter( const QString & _param, { closePlugin(); - m_plugin = _value; - if( ( m_handle = fst_load( -#ifdef QT4 - m_plugin.constData().toAscii() -#else - m_plugin.ascii() -#endif - ) ) == NULL ) + m_pluginDLL = _value; + m_plugin = new remoteVSTPlugin( m_pluginDLL ); + if( m_plugin->failed() ) { QMessageBox::information( this, - tr( "Failed loading plugin" ), - tr( "The VST-plugin %1 couldn't be " - "loaded for some reason." ).arg( - m_plugin ), + tr( "Failed loading VST-plugin" ), + tr( "The VST-plugin %1 could not " + "be loaded for some reason.\n" + "If it runs with other VST-" + "software under Linux, please " + "contact an LMMS-developer!" + ).arg( m_pluginDLL ), QMessageBox::Ok ); + closePlugin(); return; } - if( ( m_fst = fst_instantiate( m_handle, hostCallback, - this ) ) == NULL ) - { - QMessageBox::information( this, - tr( "Failed instantiating plugin" ), - tr( "Couldn't create an instance of " - "VST-plugin %1 for some " - "reason." ).arg( m_plugin ), - QMessageBox::Ok ); - fst_unload( m_handle ); - m_handle = NULL; - return; - } - - // set sample-rate and blocksize - m_fst->plugin->dispatcher( m_fst->plugin, effSetSampleRate, 0, - 0, NULL, mixer::inst()->sampleRate() ); - m_fst->plugin->dispatcher( m_fst->plugin, effSetBlockSize, 0, - mixer::inst()->framesPerAudioBuffer(), - NULL, 0.0f ); - // set program to zero - m_fst->plugin->dispatcher( m_fst->plugin, effSetProgram, 0, 0, - NULL, 0.0f ); - // resume - m_fst->plugin->dispatcher( m_fst->plugin, effMainsChanged, 0, - 1, NULL, 0.0f ); -/* if( fst_run_editor( m_fst ) ) - { - printf( "VeSTige: cannot create editor\n" ); - }*/ - int vst_version = m_fst->plugin->dispatcher( m_fst->plugin, - effGetVstVersion, 0, 0, - NULL, 0.0f ); - if( vst_version < 2 ) +/* if( m_plugin->vstVersion() < 2000 ) { QMessageBox::information( this, tr( "VST-plugin too old" ), tr( "The version of VST-plugin %1 " "is smaller than 2, which " "isn't supported." ).arg( - m_plugin ), + m_pluginDLL ), QMessageBox::Ok ); + closePlugin(); return; - } -/* printf("WID:%d %d\n", (int)fst_get_XID( m_fst ), - (int)QWidget::find( fst_get_XID( m_fst ) ) );*/ - - //printf("%d\n", m_fst->plugin->numParams); + }*/ + m_plugin->showEditor(); + update(); } } @@ -259,95 +227,16 @@ void vestigeInstrument::setParameter( const QString & _param, void vestigeInstrument::play( void ) { - // the very first time, we have to adopt fst-thread - if( !s_threadAdopted ) - { - fst_adopt_thread(); - s_threadAdopted = TRUE; - } - - if( m_handle == NULL || m_fst == NULL ) + if( m_plugin == NULL ) { return; } - // first we gonna post all MIDI-events we enqueued so far - if( m_midiEvents.size() ) - { - // since MIDI-events are not received immediately, we have - // to have them stored somewhere even after dispatcher-call, - // so we create static copies of the data and post them - static VstEvents events; - static vvector cur_events; - cur_events = m_midiEvents; - m_midiEvents.clear(); - for( csize i = 0; i < cur_events.size(); ++i ) - { - events.events[i] = (VstEvent *) &cur_events[i]; - } - events.numEvents = cur_events.size(); - printf( "VeSTige: posting %d events\n", cur_events.size()); - events.reserved = 0; - m_fst->plugin->dispatcher( m_fst->plugin, effProcessEvents, - 0, 0, &events, 0.0f ); - } - - // now we're ready to fetch sound from VST-plugin const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); - - int ch_in = m_fst->plugin->numInputs; - int ch_out = m_fst->plugin->numOutputs; - float * ins[ch_in]; - float * outs[ch_out]; - for( int i = 0; i < ch_in; ++i ) - { - ins[i] = bufferAllocator::alloc( frames ); - } - for( int i = 0; i < ch_out; ++i ) - { - outs[i] = bufferAllocator::alloc( frames ); - } - - if( m_fst->plugin->flags & effFlagsCanReplacing ) - { - m_fst->plugin->processReplacing( m_fst->plugin, ins, outs, - frames ); - - } - else - { - printf("normal process\n"); - //mixer::inst()->clearAudioBuffer( buf, frames ); - m_fst->plugin->process( m_fst->plugin, ins, outs, frames ); - printf("normal process done\n"); - } - - for( int i = 0; i < ch_in; ++i ) - { - bufferAllocator::free( ins[i] ); - } - - // got our data, now we just have to merge the 1/2 out-buffers sampleFrame * buf = bufferAllocator::alloc( frames ); - Uint8 chnls = tMax( ch_out, DEFAULT_CHANNELS ); - if( chnls != DEFAULT_CHANNELS ) - { - mixer::inst()->clearAudioBuffer( buf, frames ); - } - - for( Uint32 f = 0; f < frames; ++f ) - { - for( Uint8 chnl = 0; chnl < chnls; ++chnl ) - { - buf[f][chnl] = outs[chnl][f]; - } - } - - for( int i = 0; i < ch_out; ++i ) - { - bufferAllocator::free( outs[i] ); - } + m_plugin->process( NULL, buf ); + getChannelTrack()->processAudioBuffer( buf, frames, NULL ); bufferAllocator::free( buf ); @@ -360,9 +249,9 @@ void vestigeInstrument::play( void ) void vestigeInstrument::playNote( notePlayHandle * _n ) { - if( _n->totalFramesPlayed() == 0 ) + if( _n->totalFramesPlayed() == 0 && m_plugin != NULL ) { - enqueueEvent( midiEvent( NOTE_ON, 0, _n->key(), + m_plugin->enqueueMidiEvent( midiEvent( NOTE_ON, 0, _n->key(), _n->getVolume() ), _n->framesAhead() ); } } @@ -372,7 +261,11 @@ void vestigeInstrument::playNote( notePlayHandle * _n ) void vestigeInstrument::deleteNotePluginData( notePlayHandle * _n ) { - enqueueEvent( midiEvent( NOTE_OFF, 0, _n->key(), 0 ) ); + if( m_plugin != NULL ) + { + m_plugin->enqueueMidiEvent( midiEvent( NOTE_OFF, 0, _n->key(), + 0 ), 0 ); + } } @@ -388,12 +281,12 @@ void vestigeInstrument::openPlugin( void ) #endif QString dir; - if( m_plugin != "" ) + if( m_pluginDLL != "" ) { #ifdef QT4 - dir = QFileInfo( m_plugin ).absolutePath(); + dir = QFileInfo( m_pluginDLL ).absolutePath(); #else - dir = QFileInfo( m_plugin ).dirPath( TRUE ); + dir = QFileInfo( m_pluginDLL ).dirPath( TRUE ); #endif } else @@ -416,10 +309,10 @@ void vestigeInstrument::openPlugin( void ) ofd.addFilter( tr( "EXE-files (*.exe)" ) ); ofd.setSelectedFilter( tr( "DLL-files (*.dll)" ) ); #endif - if( m_plugin != "" ) + if( m_pluginDLL != "" ) { // select previously opened file - ofd.selectFile( QFileInfo( m_plugin ).fileName() ); + ofd.selectFile( QFileInfo( m_pluginDLL ).fileName() ); } if ( ofd.exec () == QDialog::Accepted ) @@ -435,6 +328,30 @@ void vestigeInstrument::openPlugin( void ) +void vestigeInstrument::toggleGUI( void ) +{ + if( m_plugin == NULL ) + { + return; + } + QWidget * w = m_plugin->pluginWidget(); + if( w == NULL ) + { + return; + } + if( w->isHidden() ) + { + w->show(); + } + else + { + w->hide(); + } +} + + + + void vestigeInstrument::paintEvent( QPaintEvent * ) { #ifdef QT4 @@ -448,12 +365,9 @@ void vestigeInstrument::paintEvent( QPaintEvent * ) p.drawPixmap( 0, 0, *s_artwork ); - QString plugin_name = ( m_handle != NULL && m_fst != NULL ) ? - QString( m_handle->name ) + " " + - QString::number( m_fst->plugin->dispatcher( - m_fst->plugin, - effGetVendorVersion, - 0, 0, NULL, 0.0f ) ): + QString plugin_name = ( m_plugin ) ? + QString( m_plugin->name() ) + : tr( "No VST-plugin loaded" ); QFont f = p.font(); f.setBold( TRUE ); @@ -462,15 +376,13 @@ void vestigeInstrument::paintEvent( QPaintEvent * ) p.drawText( 20, 80, plugin_name ); - if( m_handle != NULL && m_fst != NULL ) + if( m_plugin != NULL ) { p.setPen( QColor( 64, 128, 64 ) ); f.setBold( FALSE ); p.setFont( pointSize<8>( f ) ); - char buf[1024]; - m_fst->plugin->dispatcher( m_fst->plugin, effGetVendorString, - 0, 0, buf, 0 ); - p.drawText( 20, 94, tr( "by" ) + " " + QString( buf ) ); + p.drawText( 20, 94, tr( "by" ) + " " + + m_plugin->vendorString() ); } #ifndef QT4 bitBlt( this, rect().topLeft(), &pm ); @@ -482,364 +394,8 @@ void vestigeInstrument::paintEvent( QPaintEvent * ) void vestigeInstrument::closePlugin( void ) { - if( m_fst != NULL && m_handle != NULL ) - { - //fst_destroy_editor( m_fst ); - printf( "closing VST-plugin" ); - fst_close( m_fst ); - printf( "unloading VST-plugin" ); - fst_unload( m_handle ); - m_fst = NULL; - m_handle = NULL; - } -} - - - - -void vestigeInstrument::enqueueEvent( const midiEvent & _e, - Uint32 _frames_ahead ) -{ - if( m_handle == NULL || m_fst == NULL ) - { - return; - } - - VstMidiEvent event; - - event.type = kVstMidiType; - event.byteSize = 24; - event.deltaFrames = _frames_ahead; - event.flags = 0; - event.detune = 0; - event.noteLength = 0; - event.noteOffset = 0; - event.noteOffVelocity = 0; - event.reserved1 = 0; - event.reserved2 = 0; - event.midiData[0] = _e.m_type + _e.m_channel; - event.midiData[1] = _e.key(); - event.midiData[2] = _e.velocity(); - event.midiData[3] = 0; - - m_midiEvents.push_back( event ); -} - - - -#define DEBUG_CALLBACKS -#ifdef DEBUG_CALLBACKS -#define SHOW_CALLBACK printf -#else -#define SHOW_CALLBACK(...) -#endif - -long vestigeInstrument::hostCallback( AEffect * _effect, long _opcode, - long _index, long _value, void * _ptr, - float _opt ) -{ - static VstTimeInfo _timeInfo; - - SHOW_CALLBACK( "host-callback, opcode = %d", (int) _opcode ); - - switch( _opcode ) - { - case audioMasterAutomate: - SHOW_CALLBACK( "amc: audioMasterAutomate\n" ); - // index, value, returns 0 - _effect->setParameter( _effect, _index, _opt ); - return( 0 ); - - case audioMasterVersion: - SHOW_CALLBACK( "amc: audioMasterVersion\n" ); - // vst version, currently 2 (0 for older) - return( 2 ); - - case audioMasterCurrentId: - SHOW_CALLBACK( "amc: audioMasterCurrentId\n" ); - // returns the unique id of a plug that's currently - // loading - return( 0 ); - - case audioMasterIdle: - SHOW_CALLBACK ("amc: audioMasterIdle\n"); - // call application idle routine (this will - // call effEditIdle for all open editors too) - _effect->dispatcher( _effect, effEditIdle, 0, 0, NULL, - 0.0f ); - return( 0 ); - - case audioMasterPinConnected: - SHOW_CALLBACK( "amc: audioMasterPinConnected\n" ); - // inquire if an input or output is beeing connected; - // index enumerates input or output counting from zero: - // value is 0 for input and != 0 otherwise. note: the - // return value is 0 for such that older versions - // will always return true. - return( 1 ); - - case audioMasterWantMidi: - SHOW_CALLBACK( "amc: audioMasterWantMidi\n" ); - // is a filter which is currently ignored - return( 0 ); - - case audioMasterGetTime: - SHOW_CALLBACK( "amc: audioMasterGetTime\n" ); - // returns const VstTimeInfo* (or 0 if not supported) - // should contain a mask indicating which - // fields are required (see valid masks above), as some - // items may require extensive conversions - - memset( &_timeInfo, 0, sizeof( _timeInfo ) ); - - //tstate = jack_transport_query (jackvst->client, &jack_pos); - _timeInfo.samplePos = 0; - _timeInfo.sampleRate = mixer::inst()->sampleRate(); - _timeInfo.flags = 0; - _timeInfo.tempo = songEditor::inst()->getBPM(); - _timeInfo.timeSigNumerator = 4;//(long) floor (jack_pos.beats_per_bar); - _timeInfo.timeSigDenominator = 4;//(long) floor (jack_pos.beat_type); - _timeInfo.flags |= (kVstBarsValid|kVstTempoValid); -// if (tstate == JackTransportRolling) { - _timeInfo.flags |= kVstTransportPlaying; -// } - - return( (long)&_timeInfo ); - - case audioMasterProcessEvents: - SHOW_CALLBACK( "amc: audioMasterProcessEvents\n" ); - // VstEvents* in - return( 0 ); - - case audioMasterSetTime: - SHOW_CALLBACK( "amc: audioMasterSetTime\n" ); - // VstTimenfo* in , filter in , not - // supported - - case audioMasterTempoAt: - SHOW_CALLBACK( "amc: audioMasterTempoAt\n" ); - // returns tempo (in bpm * 10000) at sample frame - // location passed in - return( 0 ); - - case audioMasterGetNumAutomatableParameters: - SHOW_CALLBACK( "amc: audioMasterGetNumAutomatable" - "Parameters\n" ); - return( 0 ); - - case audioMasterGetParameterQuantization: - SHOW_CALLBACK( "amc: audioMasterGetParameter\n" - "Quantization\n" ); - // returns the integer value for +1.0 representation, - // or 1 if full single float precision is maintained - // in automation. parameter index in (-1: all, - // any) - return( 0 ); - - case audioMasterIOChanged: - SHOW_CALLBACK( "amc: audioMasterIOChanged\n" ); - // numInputs and/or numOutputs has changed - return( 0 ); - - case audioMasterNeedIdle: - SHOW_CALLBACK( "amc: audioMasterNeedIdle\n" ); - // plug needs idle calls (outside its editor window) - return( 0 ); - - case audioMasterSizeWindow: - // TODO using lmms-main-window-size - SHOW_CALLBACK( "amc: audioMasterSizeWindow\n" ); - // index: width, value: height - return( 0 ); - - case audioMasterGetSampleRate: - // TODO using mixer-call - SHOW_CALLBACK( "amc: audioMasterGetSampleRate\n" ); - return( 0 ); - - case audioMasterGetBlockSize: - // TODO using mixer-call - SHOW_CALLBACK( "amc: audioMasterGetBlockSize\n" ); - return( 0 ); - - case audioMasterGetInputLatency: - // TODO using mixer-call - SHOW_CALLBACK( "amc: audioMasterGetInputLatency\n" ); - return( 0 ); - - case audioMasterGetOutputLatency: - // TODO using mixer-call - SHOW_CALLBACK( "amc: audioMasterGetOutputLatency\n" ); - return( 0 ); - - case audioMasterGetPreviousPlug: - SHOW_CALLBACK( "amc: audioMasterGetPreviousPlug\n" ); - // input pin in (-1: first to come), returns - // cEffect* - return( 0 ); - - case audioMasterGetNextPlug: - SHOW_CALLBACK( "amc: audioMasterGetNextPlug\n" ); - // output pin in (-1: first to come), returns - // cEffect* - return( 0 ); - - case audioMasterWillReplaceOrAccumulate: - SHOW_CALLBACK( "amc: audioMasterWillReplaceOr" - "Accumulate\n" ); - // returns: 0: not supported, 1: replace, 2: accumulate - return( 0 ); - - case audioMasterGetCurrentProcessLevel: - SHOW_CALLBACK( "amc: audioMasterGetCurrentProcess" - "Level\n" ); - // returns: 0: not supported, - // 1: currently in user thread (gui) - // 2: currently in audio thread (where process is - // called) - // 3: currently in 'sequencer' thread (midi, timer etc) - // 4: currently offline processing and thus in user - // thread - // other: not defined, but probably pre-empting user - // thread. - return( 0 ); - - case audioMasterGetAutomationState: - SHOW_CALLBACK( "amc: audioMasterGetAutomationState\n" ); - // returns 0: not supported, 1: off, 2:read, 3:write, - // 4:read/write offline - return( 0 ); - - case audioMasterOfflineStart: - SHOW_CALLBACK( "amc: audioMasterOfflineStart\n" ); - return( 0 ); - - case audioMasterOfflineRead: - SHOW_CALLBACK( "amc: audioMasterOfflineRead\n" ); - // ptr points to offline structure, see below. - // return 0: error, 1 ok - return( 0 ); - - case audioMasterOfflineWrite: - SHOW_CALLBACK( "amc: audioMasterOfflineWrite\n" ); - // same as read - return( 0 ); - - case audioMasterOfflineGetCurrentPass: - SHOW_CALLBACK( "amc: audioMasterOfflineGetCurrent" - "Pass\n" ); - return( 0 ); - - case audioMasterOfflineGetCurrentMetaPass: - SHOW_CALLBACK( "amc: audioMasterOfflineGetCurrentMeta" - "Pass\n"); - return( 0 ); - - case audioMasterSetOutputSampleRate: - SHOW_CALLBACK( "amc: audioMasterSetOutputSample" - "Rate\n" ); - // for variable i/o, sample rate in - return( 0 ); - - case audioMasterGetSpeakerArrangement: - SHOW_CALLBACK( "amc: audioMasterGetSpeaker" - "Arrangement\n" ); - // (long)input in , output in - return( 0 ); - - case audioMasterGetVendorString: - SHOW_CALLBACK( "amc: audioMasterGetVendorString\n" ); - // fills with a string identifying the vendor - // (max 64 char) - strcpy( (char *) _ptr, "LAD"); - return( 0 ); - - case audioMasterGetProductString: - SHOW_CALLBACK( "amc: audioMasterGetProductString\n" ); - // fills with a string with product name - // (max 64 char) - strcpy( (char *) _ptr, "VeSTige" ); - return( 0 ); - - case audioMasterGetVendorVersion: - SHOW_CALLBACK( "amc: audioMasterGetVendorVersion\n" ); - // TODO - // returns vendor-specific version - return( 1000 ); - - case audioMasterVendorSpecific: - SHOW_CALLBACK( "amc: audioMasterVendorSpecific\n" ); - // no definition, vendor specific handling - return( 0 ); - - case audioMasterSetIcon: - SHOW_CALLBACK( "amc: audioMasterSetIcon\n" ); - // TODO - // void* in , format not defined yet - return( 0 ); - - case audioMasterCanDo: - SHOW_CALLBACK( "amc: audioMasterCanDo\n" ); - // string in ptr, see below - return( 0 ); - - case audioMasterGetLanguage: - SHOW_CALLBACK( "amc: audioMasterGetLanguage\n" ); - // TODO - // see enum - return( 0 ); - - case audioMasterOpenWindow: - SHOW_CALLBACK( "amc: audioMasterOpenWindow\n" ); - // TODO - // returns platform specific ptr - return( 0 ); - - case audioMasterCloseWindow: - SHOW_CALLBACK( "amc: audioMasterCloseWindow\n" ); - // TODO - // close window, platform specific handle in - return( 0 ); - - case audioMasterGetDirectory: - SHOW_CALLBACK( "amc: audioMasterGetDirectory\n" ); - // TODO - // get plug directory, FSSpec on MAC, else char* - return( 0 ); - - case audioMasterUpdateDisplay: - SHOW_CALLBACK( "amc: audioMasterUpdateDisplay\n" ); - // something has changed, update 'multi-fx' display - _effect->dispatcher( _effect, effEditIdle, 0, 0, NULL, - 0.0f ); - return( 0 ); - - case audioMasterBeginEdit: - SHOW_CALLBACK( "amc: audioMasterBeginEdit\n" ); - // begin of automation session (when mouse down), - // parameter index in - return( 0 ); - - case audioMasterEndEdit: - SHOW_CALLBACK( "amc: audioMasterEndEdit\n" ); - // end of automation session (when mouse up), - // parameter index in - return( 0 ); - - case audioMasterOpenFileSelector: - SHOW_CALLBACK( "amc: audioMasterOpenFileSelector\n" ); - // open a fileselector window with VstFileSelect* - // in - return( 0 ); - - default: - SHOW_CALLBACK( "VST master dispatcher: undefed: " - "%d, %d\n", (int) _opcode, - effKeysRequired ); - break; - } - - return( 0 ); + delete m_plugin; + m_plugin = NULL; } diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index f0e94a9491..3c92220918 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -1,8 +1,9 @@ /* * vestige.h - instrument VeSTige for hosting VST-plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -30,7 +31,7 @@ #ifdef QT4 -#include +#include #else @@ -39,13 +40,13 @@ #endif -#include -#include - +#include "fstclient.h" #include "spc_bg_hndl_widget.h" class pixmapButton; +class QPushButton; +class remoteVSTPlugin; class QPixmap; @@ -74,6 +75,7 @@ public: protected slots: void openPlugin( void ); + void toggleGUI( void ); protected: @@ -83,25 +85,16 @@ protected: private: void closePlugin( void ); - void enqueueEvent( const midiEvent & _e, Uint32 _frames_ahead = 0 ); - - static long hostCallback( AEffect *, long, long, long, void *, float ); - - - static bool s_initialized; - static bool s_threadAdopted; static QPixmap * s_artwork; - FSTHandle * m_handle; - FST * m_fst; - - vvector m_midiEvents; + remoteVSTPlugin * m_plugin; pixmapButton * m_openPluginButton; + QPushButton * m_toggleGUIButton; - QString m_plugin; + QString m_pluginDLL; } ; diff --git a/src/audio/audio_alsa.cpp b/src/audio/audio_alsa.cpp index 980d27be3a..b3c7ed13d6 100644 --- a/src/audio/audio_alsa.cpp +++ b/src/audio/audio_alsa.cpp @@ -1,8 +1,9 @@ /* - * audio_alsa.cpp - device-class that implements ALSA-PCM-output + * audio_alsa.cpp - device-class which implements ALSA-PCM-output * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_device.cpp b/src/audio/audio_device.cpp index edc5bdf27c..680c646282 100644 --- a/src/audio/audio_device.cpp +++ b/src/audio/audio_device.cpp @@ -1,8 +1,9 @@ /* * audio_device.cpp - base-class for audio-devices used by LMMS-mixer * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -94,6 +95,29 @@ void audioDevice::writeBuffer( surroundSampleFrame * _ab, Uint32 _frames, } + + +void audioDevice::registerPort( audioPort * ) +{ +} + + + + +void audioDevice::unregisterPort( audioPort * _port ) +{ +} + + + + +void audioDevice::renamePort( audioPort *, const QString & ) +{ +} + + + + #ifndef HAVE_SAMPLERATE_H const Uint8 LP_FILTER_TAPS = 24; const float LP_FILTER_COEFFS[LP_FILTER_TAPS] = diff --git a/src/audio/audio_file_device.cpp b/src/audio/audio_file_device.cpp index b84aae4b87..f7b822f43a 100644 --- a/src/audio/audio_file_device.cpp +++ b/src/audio/audio_file_device.cpp @@ -2,8 +2,9 @@ * audio_file_device.cpp - base-class for audio-device-classes which write * their output into a file * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_file_ogg.cpp b/src/audio/audio_file_ogg.cpp index 89aed357df..0b04f2b875 100644 --- a/src/audio/audio_file_ogg.cpp +++ b/src/audio/audio_file_ogg.cpp @@ -5,8 +5,9 @@ * This file is based on encode.c from vorbis-tools-source, for more information * see below. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_file_wave.cpp b/src/audio/audio_file_wave.cpp index 280c1b28bc..3b03d94d3f 100644 --- a/src/audio/audio_file_wave.cpp +++ b/src/audio/audio_file_wave.cpp @@ -2,8 +2,9 @@ * audio_file_wave.cpp - Audio-device which encodes wave-stream and writes it * into a WAVE-file. This is used for song-export. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_jack.cpp b/src/audio/audio_jack.cpp index 7212103635..782e2c4c8d 100644 --- a/src/audio/audio_jack.cpp +++ b/src/audio/audio_jack.cpp @@ -1,8 +1,9 @@ /* * audio_jack.cpp - support for JACK-transport * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -37,11 +38,13 @@ #include #include +#include #else #include #include +#include #endif @@ -117,14 +120,15 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : // set process-callback jack_set_process_callback( m_client, processCallback, this ); + m_jackBufSize = jack_get_buffer_size( m_client ); + // we need to know about buffer-size changes to know how long to block // in writeToDev()-method jack_set_buffer_size_callback( m_client, bufSizeCallback, this ); // set shutdown-callback - //jack_on_shutdown( m_client, shutdown, this ); + jack_on_shutdown( m_client, shutdownCallback, this ); - m_jackBufSize = jack_get_buffer_size( m_client ); if( jack_get_sample_rate( m_client ) != sampleRate() ) @@ -161,6 +165,19 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : return; } + + // make sure, JACK transport is rolling + if( jack_transport_query( m_client, NULL ) != JackTransportRolling ) + { + jack_transport_start( m_client ); + } + + + // try to sync JACK's and LMMS's buffer-size + jack_set_buffer_size( m_client, mixer::inst()->framesPerAudioBuffer() ); + + + const char * * ports = jack_get_ports( m_client, NULL, NULL, JackPortIsPhysical | JackPortIsInput ); @@ -186,6 +203,7 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : free( ports ); + _success_ful = TRUE; } @@ -194,8 +212,11 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : audioJACK::~audioJACK() { - jack_deactivate( m_client ); - jack_client_close( m_client ); + if( m_client != NULL ) + { + jack_deactivate( m_client ); + jack_client_close( m_client ); + } while( m_bufferSets.size() ) { @@ -216,6 +237,11 @@ audioJACK::~audioJACK() void audioJACK::writeBufferToDev( surroundSampleFrame * _ab, Uint32 _frames, float _master_gain ) { + if( m_client == NULL ) + { + return; + } + m_bufMutex.lock(); jack_transport_state_t ts = jack_transport_query( m_client, NULL ); @@ -258,10 +284,33 @@ void audioJACK::writeBufferToDev( surroundSampleFrame * _ab, Uint32 _frames, +void audioJACK::registerPort( audioPort * ) +{ +} + + + + +void audioJACK::unregisterPort( audioPort * _port ) +{ +} + + + + +void audioJACK::renamePort( audioPort *, const QString & ) +{ +} + + + + int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata ) { audioJACK * _this = static_cast( _udata ); +/* printf( "%f\n", jack_cpu_load( _this->m_client ) );*/ + #ifdef LMMS_DEBUG assert( _this != NULL ); #endif @@ -272,7 +321,8 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata ) if( ts != JackTransportRolling ) { // always decrease frame-sync-var as we would do it if running - // in normal mode, so that the mixer-thread does up + // in normal mode, so that the mixer-thread knows when to + // proceed if( _nframes < _this->m_frameSync ) { _this->m_frameSync -= _nframes; @@ -331,17 +381,20 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata ) _this->m_frameSync -= todo; } - // we have to clear the part of the buffers, we could not fill because - // no usable data is left, otherwise there's baaaaaad noise... ;-) + // we have to clear the part of the buffers, if we could not fill + // because no usable data is left, otherwise there's baaaaaad + // noise... ;-) if( done < _nframes ) { for( Uint8 ch = 0; ch < _this->channels(); ++ch ) { jack_default_audio_sample_t * b = outbufs[ch]; - for( Uint32 frame = done; frame < _nframes; ++frame ) + memset( b + done, 0, + sizeof( *b ) * ( _nframes - done ) ); +/* for( Uint32 frame = done; frame < _nframes; ++frame ) { b[frame] = 0.0f; - } + }*/ } } @@ -368,6 +421,23 @@ int audioJACK::bufSizeCallback( jack_nframes_t _nframes, void * _udata ) +void audioJACK::shutdownCallback( void * _udata ) +{ + audioJACK * _this = static_cast( _udata ); + _this->m_client = NULL; +/* QMessageBox::information( 0, setupWidget::tr( "JACK-server down" ), + setupWidget::tr( "You seem to have " + "shutdown JACK-server, so " + "LMMS is unable to proceed. " + "You should save your project " + "and restart LMMS!" ), + QMessageBox::Ok );*/ +} + + + + + audioJACK::setupWidget::setupWidget( QWidget * _parent ) : audioDevice::setupWidget( audioJACK::name(), _parent ) { diff --git a/src/audio/audio_oss.cpp b/src/audio/audio_oss.cpp index 7723085a13..0e08b4c54c 100644 --- a/src/audio/audio_oss.cpp +++ b/src/audio/audio_oss.cpp @@ -1,8 +1,9 @@ /* * audio_oss.cpp - device-class that implements OSS-PCM-output * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_port.cpp b/src/audio/audio_port.cpp new file mode 100644 index 0000000000..6329ae616a --- /dev/null +++ b/src/audio/audio_port.cpp @@ -0,0 +1,100 @@ +/* + * audio_port.cpp - base-class for objects providing sound at a port + * + * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + + +#include "audio_port.h" +#include "audio_device.h" +#include "buffer_allocator.h" + + +audioPort::audioPort( const QString & _name ) : + m_bufferUsage( NONE ), + m_firstBuffer( bufferAllocator::alloc( + mixer::inst()->framesPerAudioBuffer() ) ), + m_secondBuffer( bufferAllocator::alloc( + mixer::inst()->framesPerAudioBuffer() ) ), + m_extOutputEnabled( FALSE ), + m_nextFxChannel( -1 ) +{ + mixer::inst()->clearAudioBuffer( m_firstBuffer, + mixer::inst()->framesPerAudioBuffer() ); + mixer::inst()->clearAudioBuffer( m_secondBuffer, + mixer::inst()->framesPerAudioBuffer() ); + mixer::inst()->addAudioPort( this ); +} + + + + +audioPort::~audioPort() +{ + mixer::inst()->removeAudioPort( this ); + if( m_extOutputEnabled == TRUE ) + { + mixer::inst()->audioDev()->unregisterPort( this ); + } + bufferAllocator::free( m_firstBuffer ); + bufferAllocator::free( m_secondBuffer ); +} + + + + +void audioPort::nextPeriod( void ) +{ + mixer::inst()->clearAudioBuffer( m_firstBuffer, + mixer::inst()->framesPerAudioBuffer() ); + qSwap( m_firstBuffer, m_secondBuffer ); + // this is how we decrease state of buffer-usage ;-) + m_bufferUsage = ( m_bufferUsage != NONE ) ? + ( ( m_bufferUsage == FIRST ) ? NONE : FIRST ) : NONE; +} + + + + +void audioPort::setExtOutputEnabled( bool _enabled ) +{ + if( _enabled != m_extOutputEnabled ) + { + m_extOutputEnabled = _enabled; + if( m_extOutputEnabled ) + { + mixer::inst()->audioDev()->registerPort( this ); + } + else + { + mixer::inst()->audioDev()->unregisterPort( this ); + } + } +} + + + + +void audioPort::setName( const QString & _name ) +{ + mixer::inst()->audioDev()->renamePort( this, _name ); +} + diff --git a/src/audio/audio_sample_recorder.cpp b/src/audio/audio_sample_recorder.cpp index 352f8d25da..f49a93756b 100644 --- a/src/audio/audio_sample_recorder.cpp +++ b/src/audio/audio_sample_recorder.cpp @@ -3,8 +3,9 @@ * surround-audio-buffers into RAM, maybe later * also harddisk * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/audio/audio_sdl.cpp b/src/audio/audio_sdl.cpp index 1fcb9a1f26..6976c16571 100644 --- a/src/audio/audio_sdl.cpp +++ b/src/audio/audio_sdl.cpp @@ -1,8 +1,9 @@ /* * audio_sdl.cpp - device-class that performs PCM-output via SDL * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/about_dialog.cpp b/src/core/about_dialog.cpp index 6482de8f52..21975d77ab 100644 --- a/src/core/about_dialog.cpp +++ b/src/core/about_dialog.cpp @@ -1,8 +1,9 @@ /* * about_dialog.cpp - implementation of about-dialog * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index 8e2bb8b5af..610888a3d7 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -2,8 +2,9 @@ * arp_and_chords_tab_widget.cpp - widget for use in arp/chord-tab of * channel-window * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/bb_editor.cpp b/src/core/bb_editor.cpp index 8ae7f3a693..24fb6540c2 100644 --- a/src/core/bb_editor.cpp +++ b/src/core/bb_editor.cpp @@ -1,8 +1,9 @@ /* * bb_editor.cpp - basic main-window for editing of beats and basslines * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index bdd98bc665..7a673fa863 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -1,8 +1,9 @@ /* * config_mgr.cpp - implementation of class configManager * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 4e0b97bf88..577c1e850b 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -2,8 +2,9 @@ * envelope_widget.cpp - widget which is m_used by envelope/lfo/filter-tab of * channel-window * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/envelope_tab_widget.cpp b/src/core/envelope_tab_widget.cpp index c8399a19ab..4e06e71a65 100644 --- a/src/core/envelope_tab_widget.cpp +++ b/src/core/envelope_tab_widget.cpp @@ -2,8 +2,9 @@ * envelope_tab_widget.cpp - widget for use in envelope/lfo/filter-tab of * channel-window * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/export_project_dialog.cpp b/src/core/export_project_dialog.cpp index 3f49936668..ac55707c1b 100644 --- a/src/core/export_project_dialog.cpp +++ b/src/core/export_project_dialog.cpp @@ -1,8 +1,9 @@ /* * export_project_dialog.cpp - implementation of dialog for exporting project * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index eefb3d4c03..85f3dc878c 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -1,8 +1,9 @@ /* * file_browser.cpp - implementation of the project-, preset- and sample-file-browser * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/instrument.cpp b/src/core/instrument.cpp index 8b19aa2446..6306662dcf 100644 --- a/src/core/instrument.cpp +++ b/src/core/instrument.cpp @@ -1,8 +1,9 @@ /* * instrument.cpp - base-class for all instrument-plugins (synths, samplers etc) * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/main.cpp b/src/core/main.cpp index 799079992d..a18c069e51 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1,8 +1,9 @@ /* * main.cpp - just main.cpp which is starting up app... * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/midi_tab_widget.cpp b/src/core/midi_tab_widget.cpp index 160ef916fa..87ee48d46c 100644 --- a/src/core/midi_tab_widget.cpp +++ b/src/core/midi_tab_widget.cpp @@ -2,8 +2,9 @@ * midi_tab_widget.cpp - tab-widget in channel-track-window for setting up * MIDI-related stuff * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index 8fc8a0760f..adea1b3fec 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -1,8 +1,9 @@ /* * mixer.cpp - audio-device-independent mixer for LMMS * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -30,6 +31,7 @@ #include "buffer_allocator.h" #include "debug.h" #include "config_mgr.h" +#include "audio_port.h" #include "audio_device.h" #include "midi_client.h" @@ -59,13 +61,11 @@ mixer::mixer() : QObject(), #endif QThread(), - m_silence(), +/* m_silence(), #ifndef DISABLE_SURROUND m_surroundSilence(), -#endif +#endif*/ m_framesPerAudioBuffer( DEFAULT_BUFFER_SIZE ), - m_buffer1( NULL ), - m_buffer2( NULL ), m_curBuf( NULL ), m_nextBuf( NULL ), m_discardCurBuf( FALSE ), @@ -91,26 +91,17 @@ mixer::mixer() : QString::number( m_framesPerAudioBuffer ) ); } - m_buffer1 = bufferAllocator::alloc( + m_curBuf = bufferAllocator::alloc( m_framesPerAudioBuffer ); - m_buffer2 = bufferAllocator::alloc( + m_nextBuf = bufferAllocator::alloc( m_framesPerAudioBuffer ); - m_curBuf = m_buffer1; - m_nextBuf = m_buffer2; - m_audioDev = tryAudioDevices(); m_midiClient = tryMIDIClients(); - for( int i = 0; i < MAX_SAMPLE_PACKETS; ++i ) - { - m_samplePackets[i].m_buffer = NULL; - m_samplePackets[i].m_state = samplePacket::UNUSED; - } - - m_silence = bufferAllocator::alloc( +/* m_silence = bufferAllocator::alloc( m_framesPerAudioBuffer ); #ifndef DISABLE_SURROUND m_surroundSilence = bufferAllocator::alloc( @@ -128,11 +119,11 @@ mixer::mixer() : m_surroundSilence[frame][chnl] = 0.0f; } #endif - } + }*/ // now clear our two output-buffers before using them... - clearAudioBuffer( m_buffer1, m_framesPerAudioBuffer ); - clearAudioBuffer( m_buffer2, m_framesPerAudioBuffer ); + clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer ); + clearAudioBuffer( m_nextBuf, m_framesPerAudioBuffer ); } @@ -144,21 +135,14 @@ mixer::~mixer() delete m_audioDev; delete m_midiClient; - bufferAllocator::free( m_buffer1 ); - bufferAllocator::free( m_buffer2 ); + bufferAllocator::free( m_curBuf ); + bufferAllocator::free( m_nextBuf ); - for( int i = 0; i < MAX_SAMPLE_PACKETS; ++i ) - { - if( m_samplePackets[i].m_state != samplePacket::UNUSED ) - { - bufferAllocator::free( m_samplePackets[i].m_buffer ); - } - } - bufferAllocator::free( m_silence ); +/* bufferAllocator::free( m_silence ); #ifndef DISABLE_SURROUND bufferAllocator::free( m_surroundSilence ); -#endif +#endif*/ } @@ -235,32 +219,15 @@ void mixer::run( void ) songEditor::inst()->processNextBuffer(); - // check for samples-packets that have to be mixed in - // the current audio-buffer - for( int i = 0; i < MAX_SAMPLE_PACKETS; ++i ) + for( vvector::iterator it = m_audioPorts.begin(); + it != m_audioPorts.end(); ++it ) { - if( m_samplePackets[i].m_state == samplePacket::READY ) + if( ( *it )->m_bufferUsage != audioPort::NONE ) { - if( m_samplePackets[i].m_framesAhead <= - m_framesPerAudioBuffer ) - { - // found one! mix it... - mixSamplePacket( &m_samplePackets[i] ); - // now this audio-sample can be used - // again - bufferAllocator::free( - m_samplePackets[i].m_buffer ); - m_samplePackets[i].m_state = - samplePacket::UNUSED; - } - else - { - m_samplePackets[i].m_framesAhead -= - m_framesPerAudioBuffer; - } - + processBuffer( ( *it )->firstBuffer(), + ( *it )->nextFxChannel() ); + ( *it )->nextPeriod(); } - } if( !m_discardCurBuf ) @@ -280,7 +247,7 @@ void mixer::run( void ) } emit nextAudioBuffer( m_curBuf, m_framesPerAudioBuffer ); - + usleep( 1 ); // give time to other threads/processes m_safetySyncMutex.unlock(); @@ -318,7 +285,8 @@ void mixer::clear( void ) void FASTCALL mixer::clearAudioBuffer( sampleFrame * _ab, Uint32 _frames ) { - if( _frames == m_framesPerAudioBuffer ) + memset( _ab, 0, sizeof( *_ab ) * _frames ); +/* if( _frames == m_framesPerAudioBuffer ) { memcpy( _ab, m_silence, m_framesPerAudioBuffer * BYTES_PER_FRAME ); @@ -332,7 +300,7 @@ void FASTCALL mixer::clearAudioBuffer( sampleFrame * _ab, Uint32 _frames ) _ab[frame][ch] = 0.0f; } } - } + }*/ } @@ -341,7 +309,8 @@ void FASTCALL mixer::clearAudioBuffer( sampleFrame * _ab, Uint32 _frames ) void FASTCALL mixer::clearAudioBuffer( surroundSampleFrame * _ab, Uint32 _frames ) { - if( _frames == m_framesPerAudioBuffer ) + memset( _ab, 0, sizeof( *_ab ) * _frames ); +/* if( _frames == m_framesPerAudioBuffer ) { memcpy( _ab, m_surroundSilence, m_framesPerAudioBuffer * BYTES_PER_SURROUND_FRAME ); @@ -355,59 +324,52 @@ void FASTCALL mixer::clearAudioBuffer( surroundSampleFrame * _ab, _ab[frame][ch] = 0.0f; } } - } + }*/ } #endif -void FASTCALL mixer::addBuffer( sampleFrame * _buf, Uint32 _frames, +void FASTCALL mixer::bufferToPort( sampleFrame * _buf, Uint32 _frames, Uint32 _frames_ahead, - volumeVector & _volume_vector ) + volumeVector & _volume_vector, + audioPort * _port ) { -#ifdef LMMS_DEBUG - bool success = FALSE; -#endif - for ( Uint16 i = 0; i < MAX_SAMPLE_PACKETS; ++i ) + Uint32 start_frame = _frames_ahead % m_framesPerAudioBuffer; + Uint32 end_frame = start_frame + _frames; + Uint32 loop1_frame = tMin( end_frame, m_framesPerAudioBuffer ); + for( Uint32 frame = start_frame; frame < loop1_frame; ++frame ) { - if( m_samplePackets[i].m_state == samplePacket::UNUSED ) + for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) { - m_samplePackets[i].m_state = samplePacket::FILLING; - m_samplePackets[i].m_frames = _frames;//m_framesPerAudioBuffer; - m_samplePackets[i].m_framesDone = 0; - m_samplePackets[i].m_framesAhead = _frames_ahead; - - m_samplePackets[i].m_buffer = - bufferAllocator::alloc( - m_framesPerAudioBuffer ); - // now we have to make a surround-buffer out of a - // stereo-buffer (could be done more easily if there - // would be no volume-vector...) - for( Uint32 frame = 0; frame < _frames/*m_framesPerAudioBuffer*/; - ++frame ) - { - for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; - ++chnl ) - { - m_samplePackets[i].m_buffer[frame][chnl] = - _buf[frame][chnl%DEFAULT_CHANNELS] * + _port->firstBuffer()[frame][chnl] += + _buf[frame - start_frame][chnl % + DEFAULT_CHANNELS] * _volume_vector.vol[chnl]; - } - } - - m_samplePackets[i].m_state = samplePacket::READY; -#ifdef LMMS_DEBUG - success = TRUE; -#endif - break; } } -#ifdef LMMS_DEBUG - if( success == FALSE ) + if( end_frame > m_framesPerAudioBuffer ) { - qWarning( "No sample-packets left in mixer::addBuffer(...)!\n" ); + Uint32 frames_done = m_framesPerAudioBuffer - start_frame; + end_frame = tMin( end_frame -= m_framesPerAudioBuffer, + m_framesPerAudioBuffer ); + for( Uint32 frame = 0; frame < end_frame; ++frame ) + { + for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) + { + _port->secondBuffer()[frame][chnl] += + _buf[frames_done + frame][chnl % + DEFAULT_CHANNELS] * + _volume_vector.vol[chnl]; + } + } + _port->m_bufferUsage = audioPort::BOTH; } -#endif + else if( _port->m_bufferUsage == audioPort::NONE ) + { + _port->m_bufferUsage = audioPort::FIRST; + } + } @@ -509,51 +471,6 @@ void mixer::checkValidityOfPlayHandles( void ) -void FASTCALL mixer::mixSamplePacket( samplePacket * _sp ) -{ - Uint32 start_frame = _sp->m_framesAhead % m_framesPerAudioBuffer; - Uint32 end_frame = start_frame + _sp->m_frames;//m_framesPerAudioBuffer; - - if( end_frame <= m_framesPerAudioBuffer ) - { - for( Uint32 frame = start_frame; frame < end_frame; ++frame ) - { - for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) - { - m_curBuf[frame][chnl] += - _sp->m_buffer[frame-start_frame][chnl]; - } - } - } - else - { - for( Uint32 frame = start_frame; frame < - m_framesPerAudioBuffer; ++frame ) - { - for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) - { - m_curBuf[frame][chnl] += - _sp->m_buffer[frame-start_frame][chnl]; - } - } - - Uint32 frames_done = m_framesPerAudioBuffer - start_frame; - end_frame = tMin( end_frame -= m_framesPerAudioBuffer, - m_framesPerAudioBuffer ); - - for( Uint32 frame = 0; frame < end_frame; ++frame ) - { - for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) - { - m_nextBuf[frame][chnl] += - _sp->m_buffer[frames_done+frame][chnl]; - } - } - } -} - - - audioDevice * mixer::tryAudioDevices( void ) { @@ -693,5 +610,19 @@ midiClient * mixer::tryMIDIClients( void ) + +void mixer::processBuffer( surroundSampleFrame * _buf, fxChnl/* _fx_chnl */ ) +{ + // TODO: effect-implementation + for( Uint32 frame = 0; frame < m_framesPerAudioBuffer; ++frame ) + { + for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) + { + m_curBuf[frame][chnl] += _buf[frame][chnl]; + } + } +} + + #include "mixer.moc" diff --git a/src/core/name_label.cpp b/src/core/name_label.cpp index 49a947c163..b96b727436 100644 --- a/src/core/name_label.cpp +++ b/src/core/name_label.cpp @@ -2,8 +2,9 @@ * name_label.cpp - implementation of class nameLabel, a label which * is renamable by double-clicking it * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/note.cpp b/src/core/note.cpp index d9ccab3bb6..bae3a8319d 100644 --- a/src/core/note.cpp +++ b/src/core/note.cpp @@ -1,8 +1,9 @@ /* * note.cpp - implementation of class note * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index e4195ba96c..51214479ec 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -2,8 +2,9 @@ * note_play_handle.cpp - implementation of class notePlayHandle, part of * play-engine * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/piano_roll.cpp b/src/core/piano_roll.cpp index 4e04a7893c..daa9e02a45 100644 --- a/src/core/piano_roll.cpp +++ b/src/core/piano_roll.cpp @@ -2,8 +2,9 @@ * piano_roll.cpp - implementation of piano-roll which is used for actual * writing of melodies * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/piano_widget.cpp b/src/core/piano_widget.cpp index c5826fd098..444fbf0fa9 100644 --- a/src/core/piano_widget.cpp +++ b/src/core/piano_widget.cpp @@ -2,8 +2,9 @@ * piano_widget.cpp - implementation of piano-widget used in channel-window * for testing channel * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index b1918612d0..45d65de57a 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -1,8 +1,9 @@ /* * plugin.cpp - implemenation of plugin-class including plugin-loader * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -93,7 +94,7 @@ plugin * plugin::instantiate( const QString & _plugin_name, void * _data ) #else ascii() #endif - , RTLD_LAZY ); + , RTLD_NOW ); if( handle == NULL ) { QMessageBox::information( NULL, @@ -132,7 +133,7 @@ plugin * plugin::instantiate( const QString & _plugin_name, void * _data ) void plugin::getDescriptorsOfAvailPlugins( vvector & _plugin_descs ) { QDir directory( configManager::inst()->pluginDir() ); - const QFileInfoList * list = directory.entryInfoList( "*.so" ); + const QFileInfoList * list = directory.entryInfoList( "lib*.so" ); if( list == NULL ) { return; @@ -141,7 +142,7 @@ void plugin::getDescriptorsOfAvailPlugins( vvector & _plugin_descs ) file != list->end(); ++file ) { void * handle = dlopen( ( *file )->absFilePath().latin1(), - RTLD_LAZY ); + RTLD_NOW ); char * msg = dlerror(); if( msg != NULL || handle == NULL ) { diff --git a/src/core/plugin_browser.cpp b/src/core/plugin_browser.cpp index 1dea45b21b..a28f9aa1f9 100644 --- a/src/core/plugin_browser.cpp +++ b/src/core/plugin_browser.cpp @@ -1,8 +1,9 @@ /* * plugin_browser.cpp - implementation of the plugin-browser * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/preset_preview_play_handle.cpp b/src/core/preset_preview_play_handle.cpp index b55c779268..463e66af44 100644 --- a/src/core/preset_preview_play_handle.cpp +++ b/src/core/preset_preview_play_handle.cpp @@ -2,8 +2,9 @@ * preset_preview_play_handle.cpp - implementation of class * presetPreviewPlayHandle * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/sample_play_handle.cpp b/src/core/sample_play_handle.cpp index 2822849d8e..9e50e31f24 100644 --- a/src/core/sample_play_handle.cpp +++ b/src/core/sample_play_handle.cpp @@ -1,8 +1,9 @@ /* * sample_play_handle.cpp - implementation of class samplePlayHandle * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -30,6 +31,8 @@ #include "sample_play_handle.h" #include "sample_buffer.h" #include "buffer_allocator.h" +#include "audio_port.h" + samplePlayHandle::samplePlayHandle( const QString & _sample_file ) : @@ -37,17 +40,21 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file ) : m_sampleBuffer( new sampleBuffer( _sample_file ) ), m_ownSampleBuffer( TRUE ), m_doneMayReturnTrue( TRUE ), - m_frame( 0 ) + m_frame( 0 ), + m_audioPort( new audioPort( "samplePlayHandle" ) ) { } + + samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) : playHandle(), m_sampleBuffer( _sample_buffer ), m_ownSampleBuffer( FALSE ), m_doneMayReturnTrue( TRUE ), - m_frame( 0 ) + m_frame( 0 ), + m_audioPort( new audioPort( "samplePlayHandle" ) ) { } @@ -59,6 +66,7 @@ samplePlayHandle::~samplePlayHandle() { delete m_sampleBuffer; } + delete m_audioPort; } @@ -80,8 +88,8 @@ void samplePlayHandle::play( void ) #endif } ; m_sampleBuffer->play( buf, m_frame ); - mixer::inst()->addBuffer( buf, mixer::inst()->framesPerAudioBuffer(), - 0, v ); + mixer::inst()->bufferToPort( buf, mixer::inst()->framesPerAudioBuffer(), + 0, v, m_audioPort ); bufferAllocator::free( buf ); diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index ff6219204b..1fd166188a 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -1,8 +1,9 @@ /* * setup_dialog.cpp - dialog for setting up LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index b737bd8161..0b56de731a 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -1,8 +1,9 @@ /* * song_editor.cpp - basic window for editing song * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/surround_area.cpp b/src/core/surround_area.cpp index 9dd0ede087..dc42dfd335 100644 --- a/src/core/surround_area.cpp +++ b/src/core/surround_area.cpp @@ -2,8 +2,9 @@ * surround_area.cpp - a widget for setting position of a channel + * calculation of volume for each speaker * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/timeline.cpp b/src/core/timeline.cpp index 2bce7bc1c5..09a1cc5b4d 100644 --- a/src/core/timeline.cpp +++ b/src/core/timeline.cpp @@ -2,8 +2,9 @@ * playpos_marker.cpp - class timeLine, representing a time-line with * position marker * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/track.cpp b/src/core/track.cpp index 29776f9cce..593d016de9 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -2,8 +2,9 @@ * track.cpp - implementation of classes concerning tracks -> neccessary for * all track-like objects (beat/bassline, sample-track...) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/core/track_container.cpp b/src/core/track_container.cpp index 80f0907d47..9f778bd94b 100644 --- a/src/core/track_container.cpp +++ b/src/core/track_container.cpp @@ -2,8 +2,9 @@ * track_container.cpp - implementation of base-class for all track-containers * like Song-Editor, BB-Editor... * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/buffer_allocator.cpp b/src/lib/buffer_allocator.cpp index 367cec8b26..f57df2994a 100644 --- a/src/lib/buffer_allocator.cpp +++ b/src/lib/buffer_allocator.cpp @@ -2,8 +2,9 @@ * buffer_allocator.cpp - namespace bufferAllocator providing routines for own * optimized memory-management for audio-buffers * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/clipboard.cpp b/src/lib/clipboard.cpp index 20f74a498b..88f998fd34 100644 --- a/src/lib/clipboard.cpp +++ b/src/lib/clipboard.cpp @@ -1,8 +1,9 @@ /* * clipboard.cpp - the clipboard for patterns, notes etc. * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/embed.cpp b/src/lib/embed.cpp index 5edb2bdd11..de8da7c4c6 100644 --- a/src/lib/embed.cpp +++ b/src/lib/embed.cpp @@ -1,8 +1,9 @@ /* * embed.cpp - misc stuff for using embedded resources (linked into binary) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/ladspa_manager.cpp b/src/lib/ladspa_manager.cpp index 88bdba73d0..21d8543ffa 100644 --- a/src/lib/ladspa_manager.cpp +++ b/src/lib/ladspa_manager.cpp @@ -2,8 +2,9 @@ * ladspa_manager.cpp - a class to manage loading and instantiation * of ladspa plugins * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Danny McRae + * Copyright (c) 2005 Danny McRae + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/mmp.cpp b/src/lib/mmp.cpp index 970554267c..6b9de75a6e 100644 --- a/src/lib/mmp.cpp +++ b/src/lib/mmp.cpp @@ -1,8 +1,9 @@ /* * mmp.cpp - implementation of class multimediaProject * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/oscillator.cpp b/src/lib/oscillator.cpp index 326947bc6b..e78c8b4f1b 100644 --- a/src/lib/oscillator.cpp +++ b/src/lib/oscillator.cpp @@ -1,8 +1,9 @@ /* * oscillator.cpp - implementation of powerful oscillator-class * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/lib/sample_buffer.cpp b/src/lib/sample_buffer.cpp index 444d7ae874..f982bad509 100644 --- a/src/lib/sample_buffer.cpp +++ b/src/lib/sample_buffer.cpp @@ -1,8 +1,9 @@ /* * sample_buffer.cpp - container-class sampleBuffer * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -261,20 +262,22 @@ m_data[frame][chnl] = buf[idx] * fac; else { m_data = new sampleFrame[1]; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + memset( m_data, 0, sizeof( *m_data ) * 1 ); +/* for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { m_data[0][chnl] = 0.0f; - } + }*/ m_frames = 1; } } else { m_data = new sampleFrame[1]; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + memset( m_data, 0, sizeof( *m_data ) * 1 ); +/* for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { m_data[0][chnl] = 0.0f; - } + }*/ m_frames = 1; } diff --git a/src/lib/string_pair_drag.cpp b/src/lib/string_pair_drag.cpp index d56a1b9c8c..63a231f918 100644 --- a/src/lib/string_pair_drag.cpp +++ b/src/lib/string_pair_drag.cpp @@ -2,8 +2,9 @@ * string_pair_drag.cpp - class stringPairDrag which provides general support * for drag'n'drop of string-pairs * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/midi/midi_alsa_raw.cpp b/src/midi/midi_alsa_raw.cpp index 6848c70c8b..5631a7072e 100644 --- a/src/midi/midi_alsa_raw.cpp +++ b/src/midi/midi_alsa_raw.cpp @@ -1,8 +1,9 @@ /* * midi_alsa_raw.cpp - midi-client for RawMIDI via ALSA * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/midi/midi_alsa_seq.cpp b/src/midi/midi_alsa_seq.cpp index 50f824ff63..5373da9bb9 100644 --- a/src/midi/midi_alsa_seq.cpp +++ b/src/midi/midi_alsa_seq.cpp @@ -1,8 +1,9 @@ /* * midi_alsa_seq.cpp - ALSA-sequencer-client * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/midi/midi_client.cpp b/src/midi/midi_client.cpp index 9b92e18f39..43a467e3be 100644 --- a/src/midi/midi_client.cpp +++ b/src/midi/midi_client.cpp @@ -1,10 +1,11 @@ /* * midi_client.cpp - base-class for MIDI-clients like ALSA-sequencer-client * - * Linux MultiMedia Studio - * Copyright (_c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel * This file partly contains code from Fluidsynth, Peter Hanappe * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either diff --git a/src/midi/midi_mapper.cpp b/src/midi/midi_mapper.cpp index 88c306315e..d50109af83 100644 --- a/src/midi/midi_mapper.cpp +++ b/src/midi/midi_mapper.cpp @@ -1,8 +1,9 @@ /* * midi_mapper.cpp - MIDI-mapper for any midiDevice * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/midi/midi_oss.cpp b/src/midi/midi_oss.cpp index b548c16f0d..a1d96e1280 100644 --- a/src/midi/midi_oss.cpp +++ b/src/midi/midi_oss.cpp @@ -1,8 +1,9 @@ /* * midi_oss.cpp - OSS-raw-midi-client * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/midi/midi_port.cpp b/src/midi/midi_port.cpp index cb5add3fdc..cdefd1358e 100644 --- a/src/midi/midi_port.cpp +++ b/src/midi/midi_port.cpp @@ -2,9 +2,9 @@ * midi_port.cpp - abstraction of MIDI-ports which are part of LMMS's MIDI- * sequencing system * - * Linux MultiMedia Studio - * Copyright (_c) 2004-2005 Tobias Doerffel - * This file partly contains code from Fluidsynth, Peter Hanappe + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index 86988b22c9..a205cffe52 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -1,8 +1,9 @@ /* * bb_track.cpp - implementation of class bbTrack * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index e2be5d4719..af86b616f4 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -1,8 +1,9 @@ /* * pattern.cpp - implementation of class pattern which holds notes * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index be3c860ff4..b990811107 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -2,8 +2,9 @@ * sample_track.cpp - implementation of class sampleTrack, a track which * provides arrangement of samples * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -47,6 +48,7 @@ #include "templates.h" #include "buffer_allocator.h" #include "tooltip.h" +#include "audio_port.h" @@ -283,8 +285,9 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f ) -sampleTrack::sampleTrack( trackContainer * _tc ) - : track( _tc ) +sampleTrack::sampleTrack( trackContainer * _tc ) : + track( _tc ), + m_audioPort( new audioPort( tr( "Sample track" ) ) ) { getTrackWidget()->setFixedHeight( 32 ); @@ -303,6 +306,7 @@ sampleTrack::sampleTrack( trackContainer * _tc ) sampleTrack::~sampleTrack() { + delete m_audioPort; } @@ -348,10 +352,11 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame, static_cast( _start.getTact() * fpt ), _frames ); - mixer::inst()->addBuffer( buf, _frames, _frame_base + + mixer::inst()->bufferToPort( buf, _frames, _frame_base + static_cast( st->startPosition().getTact64th() * - fpt / 64.0f ), v ); + fpt / 64.0f ), v, + m_audioPort ); } } diff --git a/src/widgets/group_box.cpp b/src/widgets/group_box.cpp index cc72722aa0..f66cfc6f1c 100644 --- a/src/widgets/group_box.cpp +++ b/src/widgets/group_box.cpp @@ -1,8 +1,9 @@ /* * group_box.cpp - groupbox for LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index e36364487e..afadca7ee9 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -4,8 +4,9 @@ * This file is based on the knob-widget of the Qwt Widget Library from * Josef Wilgen * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/lcd_spinbox.cpp b/src/widgets/lcd_spinbox.cpp index bdb85852d7..22ada48060 100644 --- a/src/widgets/lcd_spinbox.cpp +++ b/src/widgets/lcd_spinbox.cpp @@ -1,8 +1,9 @@ /* * lcd_spinbox.cpp - class lcdSpinBox, an improved QLCDNumber * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/led_checkbox.cpp b/src/widgets/led_checkbox.cpp index e234676f8c..27192396ef 100644 --- a/src/widgets/led_checkbox.cpp +++ b/src/widgets/led_checkbox.cpp @@ -1,8 +1,9 @@ /* * led_checkbox.cpp - class ledCheckBox, an improved QCheckBox * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/nstate_button.cpp b/src/widgets/nstate_button.cpp index c672a8531c..6d3108851a 100644 --- a/src/widgets/nstate_button.cpp +++ b/src/widgets/nstate_button.cpp @@ -1,8 +1,9 @@ /* * nstate_button.cpp - implementation of n-state-button * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/pixmap_button.cpp b/src/widgets/pixmap_button.cpp index 74eab33fe1..69f83b6332 100644 --- a/src/widgets/pixmap_button.cpp +++ b/src/widgets/pixmap_button.cpp @@ -2,8 +2,9 @@ * pixmap_button.cpp - implementation of pixmap-button (often used as "themed" * checkboxes/radiobuttons etc) * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/project_notes.cpp b/src/widgets/project_notes.cpp index 70c839e55c..f23a60655d 100644 --- a/src/widgets/project_notes.cpp +++ b/src/widgets/project_notes.cpp @@ -1,8 +1,9 @@ /* * project_notes.cpp - implementation of project-notes-editor * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/qxembed.cpp b/src/widgets/qxembed.cpp new file mode 100644 index 0000000000..542ac50eab --- /dev/null +++ b/src/widgets/qxembed.cpp @@ -0,0 +1,1359 @@ +/**************************************************************************** + Implementation of QXEmbed class + + Copyright (C) 1999-2002 Trolltech AS + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*****************************************************************************/ + + +// L-000: About comments marked with Lxxxx. +// +// These comments represent an attempt to provide a more adequate +// documentation to KDE developpers willing to modify QXEmbed. Keep in +// mind that these comments were written long after most of the code. +// Please improve them if you spot something wrong or missing +// (Leon Bottou, 26-10-2003). +// +// Relevant documents: +// - QXEmbed developper documentation +// (see comments in qxembed.h) +// - Xlib Reference Manual +// (sections about focus, reparenting, window management) +// - ICCCM Manual +// (window management) +// - XEMBED specification +// (http://www.freedesktop.org/Standards/xembed-spec) +// - XPLAIN and XEMBED. +// +// - Accumulated community knowledge. +// +// +// +// + + +#include +#include +#include +#include +#include +#include + +// L0001: QXEmbed works only under X windows. +#ifdef Q_WS_X11 + +# include +# include +# include +# include +# define XK_MISCELLANY +# define XK_LATIN1 +# include +/*# include +# include */ + +// L0002: Is file config.h KDE specific? +# include +# ifdef HAVE_UNISTD_H +# include +# ifdef HAVE_USLEEP +# define USLEEP(x) usleep(x) +# else +# define USLEEP(x) sleep(0) +# endif +# else +# define USLEEP(x) sleep(0) +# endif + +# include "qxembed.h" + +// L0003: This keysym is used for focus navigation. +# ifndef XK_ISO_Left_Tab +# define XK_ISO_Left_Tab 0xFE20 +# endif + +// L0004: Conflicts between X11 and Qt definitions. +const int XFocusOut = FocusOut; +const int XFocusIn = FocusIn; +const int XKeyPress = KeyPress; +const int XKeyRelease = KeyRelease; +# undef KeyRelease +# undef KeyPress +# undef FocusOut +# undef FocusIn + +// L0005: Variables defined in qapplication_x11.cpp +extern Atom qt_wm_protocols; +extern Atom qt_wm_delete_window; +extern Atom qt_wm_take_focus; +extern Atom qt_wm_state; +extern Time qt_x_time; + +// L0006: X11 atoms private to QXEmbed +static Atom xembed = 0; +static Atom context_help = 0; + +// L0007: Xembed message codes (see XEmbed spec) +#define XEMBED_EMBEDDED_NOTIFY 0 +#define XEMBED_WINDOW_ACTIVATE 1 +#define XEMBED_WINDOW_DEACTIVATE 2 +#define XEMBED_REQUEST_FOCUS 3 +#define XEMBED_FOCUS_IN 4 +#define XEMBED_FOCUS_OUT 5 +#define XEMBED_FOCUS_NEXT 6 +#define XEMBED_FOCUS_PREV 7 + +// L0008: Xembed message details (see XEmbed spec) +// -- XEMBED_FOCUS_IN: +#define XEMBED_FOCUS_CURRENT 0 +#define XEMBED_FOCUS_FIRST 1 +#define XEMBED_FOCUS_LAST 2 + + +// L0100: Private data held by the QXEmbed object. +// This belongs to the embedder side. +class QXEmbedData +{ +public: + QXEmbedData(){ + autoDelete = true; + xplain = false; + xgrab = false; + mapAfterRelease = false; + lastPos = QPoint(0,0); + } + ~QXEmbedData(){}; + + bool autoDelete; // L0101: See L2600 + bool xplain; // L0102: See L1100 + bool xgrab; // L0103: See L2800 + bool mapAfterRelease; + QWidget* focusProxy; // L0104: See XEmbed spec + QPoint lastPos; // L0105: See L1390 +}; + +namespace +{ + // L0200: This application wide event filter handles focus + // issues in the embedded client. + class QXEmbedAppFilter : public QObject + { + public: + QXEmbedAppFilter() { qApp->installEventFilter( this ); } + ~QXEmbedAppFilter() { }; + bool eventFilter( QObject *, QEvent * ); + }; +} + +// L0201: See L0200, L0740 +static QXEmbedAppFilter* filter = 0; +// L0202: See L0610, L0730 +static QPtrDict > *focusMap = 0; +// L0203: See L0660, L1400, L1450 +static XKeyEvent last_key_event; + +// L0300: This class gives access protected members of class QWidget. +// Function focusData() is useful to reimplement tab focus management +// (L0620) Function topData() returns a structure QTLWExtra containing +// information unique to toplevel windows. This structure contains two +// members for the sole use of QXEmbed. Flag `embedded' indicates whether +// the toplevel window is embedded using the XEMBED protocol (L0680). +// Handle `parentWinId' then records the id of the embedding window. + +class QPublicWidget : public QWidget +{ +public: + QTLWExtra* topData() { return QWidget::topData(); } + QFocusData *focusData(){ return QWidget::focusData(); } + bool focusNextPrev(bool b) { return focusNextPrevChild(b); } +}; + +// L0400: This sets a very low level filter for X11 messages. +// See qapplication_x11.cpp +typedef int (*QX11EventFilter) (XEvent*); +extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); +static QX11EventFilter oldFilter = 0; + + +// L0500: Helper to send XEmbed messages. +static void sendXEmbedMessage( WId window, long message, long detail = 0, + long data1 = 0, long data2 = 0) +{ + if (!window) return; + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xclient.type = ClientMessage; + ev.xclient.window = window; + ev.xclient.message_type = xembed; + ev.xclient.format = 32; + ev.xclient.data.l[0] = qt_x_time; + ev.xclient.data.l[1] = message; + ev.xclient.data.l[2] = detail; + ev.xclient.data.l[3] = data1; + ev.xclient.data.l[4] = data2; + XSendEvent(qt_xdisplay(), window, false, NoEventMask, &ev); +} + +// L0501: Helper to send ICCCM Client messages. +// See X11 ICCCM Specification. +static void sendClientMessage(Window window, Atom a, long x) +{ + if (!window) return; + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xclient.type = ClientMessage; + ev.xclient.window = window; + ev.xclient.message_type = a; + ev.xclient.format = 32; + ev.xclient.data.l[0] = x; + ev.xclient.data.l[1] = qt_x_time; + XSendEvent(qt_xdisplay(), window, false, NoEventMask, &ev); +} + +// L0502: Helper to send fake X11 focus messages. +// See X11 Reference Manual and Window Management stuff. +static void sendFocusMessage(Window window, int type, int mode, int detail) +{ + if (!window) return; + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.type = type; + ev.xfocus.window = window; + ev.xfocus.mode = mode; + ev.xfocus.detail = detail; + XSendEvent(qt_xdisplay(), window, false, FocusChangeMask, &ev); +} + + +// ------------------------------------------------------------ +// L0600: MOST OF WHAT FOLLOWS CONCERNS THE CLIENT SIDE. +// The following code mostly executes inside a Qt application swallowed +// by QXEmbed widget. It mostly consists of event filters that fight +// the normal Qt mechanisms in order to implement the XEMBED protocol. +// All this would be a lot simpler if it was implemented by Qt itself. + + + +// L0610: This event filter receives all Qt events. Its main purpose is to +// capture the Qt focus events in the embedded client in order to +// implement the XEMBED protocol. +// +// Let's start with a few reminders: +// +// - X11 only has the concept of the "X11 focus window". This window +// basically receives all key events. The ICCCM conventions define +// how the window manager and the applications must cooperate to +// choose the X11 focus window. +// +// - Most toolkits, including Qt, maintain the concepts of 'active +// widget' and 'Qt focus widget'. A toplevel widget is active when +// the X11 focus is set to one of its children. By extension a +// widget is active when its toplevel widget is active. There is one +// Qt focus widget for each toplevel widget. When the toplevel +// widget is active, all key events are sent to the Qt focus widget, +// regardless of which descendant of the toplevel window has the X11 +// focus. Widgets can adjust their appearance according to both +// their activation and focus states. The Qt FocusIn and FocusOut +// events indicate when a widget simultaneously is active and has +// the Qt focus. +// +// The XEMBED protocol defines ways to communicate abouth both +// activation and focus. The embedded client is active as soon as the +// embedding window is active (L0676, L0677). A widget in the embedded +// client receives key events when (1) it has the Qt focus in the +// embedded application, and (2) the QXEmbed widget in the embedding +// application is active and has the Qt focus. The Qt library in the +// embedded application is unaware of the focus status of the QXEmbed +// widget. We must make sure it does the right thing regarding the +// sending of focus events and the visual appearance of the focussed +// widgets. When the QXEmbed widget looses the Qt focus, we clear the +// focus in the embedded client (L1570, L0688). Conversely, when +// the QXEmbed widget gains the Qt focus, we restore the Qt focus +// window in the embedded client (L1530, L0680, L0683). +// Variable focusMap is used to remember which was the Qt focus +// widget in the embedded application. All this would be a lot +// simpler if it was implemented inside Qt... +// +// The XPLAIN protocol is much less refined in this respect. +// The activation status of the embedded client simply reflect +// the focus status of the QXEmbed widget. This is achieved +// by sending fake X11 focus message to the client (L1521, L1561). +// A passive button grab (L2800) intercepts mouse activity in the +// embedded client and sets the Qt focus to the QXEmbed widget +// when this happens (L2060). This can be achieved without +// cooperation from the client. + +bool QXEmbedAppFilter::eventFilter( QObject *o, QEvent * e) +{ + static bool obeyFocus = false; + switch ( e->type() ) { + case QEvent::MouseButtonPress: + // L0612: This will become clear with L0614 + if ( !((QWidget*)o)->isActiveWindow() ) + obeyFocus = true; + break; + case QEvent::FocusIn: + // L0613: FocusIn events either occur because the widget already was + // active and has just been given the Qt focus (L0614) or + // because the widget already had the Qt focus and just became + // active (L0615). + if ( qApp->focusWidget() == o && + ((QPublicWidget*)qApp->focusWidget()->topLevelWidget())->topData()->embedded ) { + QFocusEvent* fe = (QFocusEvent*) e; + if ( obeyFocus || fe->reason() == QFocusEvent::Mouse || + fe->reason() == QFocusEvent::Shortcut ) { + // L0614: A widget in the embedded client was just given the Qt focus. + // Variable `obeyFocus' suggests that this is the result of mouse + // activity in the client. The XEMBED_REQUEST_FOCUS message causes + // the embedding widget to take the Qt focus (L2085). + WId window = ((QPublicWidget*)qApp->focusWidget()->topLevelWidget())->topData()->parentWinId; + focusMap->remove( qApp->focusWidget()->topLevelWidget() ); + sendXEmbedMessage( window, XEMBED_REQUEST_FOCUS ); + } else if ( fe->reason() == QFocusEvent::ActiveWindow ) { + // L0615: Both the embedder and the embedded client became active. + // But we do not know whether the QXEmbed widget has the Qt focus. + // So we clear the Qt focus for now. If indeed the QXEmbed widget + // has the focus, it will receive a FocusIn message (L1530) and + // tell us to restore the focus (L0680, L0683). + focusMap->remove( qApp->focusWidget()->topLevelWidget() ); + focusMap->insert( qApp->focusWidget()->topLevelWidget(), + new QGuardedPtr(qApp->focusWidget()->topLevelWidget()->focusWidget() ) ); + // L0616: qApp->focusWidget() might belong to a modal dialog and not be + // equal to qApp->focusWidget()->topLevelWidget()->focusWidget() ! + qApp->focusWidget()->clearFocus(); + // L0617: ??? [why not {obeyFocus=false; return true;} here?] + } + obeyFocus = false; + } + break; + case QEvent::KeyPress: + if (qApp->focusWidget() == o && + ((QPublicWidget*)qApp->focusWidget()->topLevelWidget())->topData()->embedded ) { + // L0620: The following code replaces the Qt code that + // handles focus focus changes with the tab key. See the + // XEMBED specification for details. The keypress event + // arrives here after an interesting itinerary. It is first + // saved in the embedding application (L0660). After being + // rejected for tab navigation in the embedding application + // (L1901), it gets forwarded to the embedded client + // (L1400) and arrives here. Depending on the status of + // the tab chain in the embedded client, focus navigation + // messages are sent back to the embedding application + // (L0653, L0654) which then performs tab navigation + // (L2081). + QKeyEvent *k = (QKeyEvent *)e; + QWidget *w = qApp->focusWidget(); + // L0621: The following tests are copied from QWidget::event(). + bool res = false; + bool tabForward = true; + if ( !(k->state() & ControlButton || k->state() & AltButton) ) { + if ( k->key() == Key_Backtab || (k->key() == Key_Tab && (k->state() & ShiftButton)) ) { + QFocusEvent::setReason( QFocusEvent::Backtab ); + res = ((QPublicWidget*)w)->focusNextPrev( tabForward = false ); + QFocusEvent::resetReason(); + } else if ( k->key() == Key_Tab ) { + QFocusEvent::setReason( QFocusEvent::Tab ); + res = ((QPublicWidget*)w)->focusNextPrev( tabForward = true ); + QFocusEvent::resetReason(); + } + } + if (res) { + // L0625: We changed the focus because of tab/backtab key + // Now check whether we have been looping around. + QFocusData *fd = ((QPublicWidget*)w)->focusData(); + WId window = ((QPublicWidget*)w->topLevelWidget())->topData()->parentWinId; + QWidget *cw = 0; + QWidget *fw = fd->home(); + if (tabForward && window) { + while (cw != w && cw != fw && cw != w->topLevelWidget()) + cw = fd->prev(); + if (cw != w) + sendXEmbedMessage( window, XEMBED_FOCUS_NEXT ); + } else if (window) { + while (cw != w && cw != fw && cw != w->topLevelWidget()) + cw = fd->next(); + if (cw != w) + sendXEmbedMessage( window, XEMBED_FOCUS_PREV ); + } + // L0628: Qt should no longer process this event. + return true; + } + } + break; + default: + break; + } + // L0640: Application gets to see the events anyway. + return false; +} + +// L0650: This filter receives all XEvents in both the client and the embedder. +// Most of it involves the embedded client (except L0660, L0671). +static int qxembed_x11_event_filter( XEvent* e) +{ + switch ( e->type ) { + case XKeyPress: + case XKeyRelease: { + // L0660: This is for the embedding side (L1450). + last_key_event = e->xkey; + break; + } + case ClientMessage: + if ( e->xclient.message_type == xembed ) { + // L0670: This is where the XEmbed messages are + // processed on the client side. + Time msgtime = (Time) e->xclient.data.l[0]; + long message = e->xclient.data.l[1]; + long detail = e->xclient.data.l[2]; + // L0671: Keep Qt message time up to date + if ( msgtime > qt_x_time ) + qt_x_time = msgtime; + QWidget* w = QWidget::find( e->xclient.window ); + if ( !w ) + break; + switch ( message) { + case XEMBED_EMBEDDED_NOTIFY: { + // L0675: We just have been embedded into a XEMBED aware widget. + QTLWExtra *extra = ((QPublicWidget*)w->topLevelWidget())->topData(); + extra->embedded = 1; + extra->parentWinId = e->xclient.data.l[3]; + w->topLevelWidget()->show(); + break; + } + case XEMBED_WINDOW_ACTIVATE: { + // L0676: Embedding window becomes active. Send a fake XFocusIn + // to convince Qt that we are active as well. Qt will send + // us a focus notification (L0615) that we will intercept to + // ensure that we have no Qt focus widget yet. The Qt focus + // widget might later be set in L0680. + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = qt_xdisplay(); + ev.xfocus.type = XFocusIn; + ev.xfocus.window = w->topLevelWidget()->winId(); + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + qApp->x11ProcessEvent( &ev ); + } + break; + case XEMBED_WINDOW_DEACTIVATE: { + // L0677: Embedding window becomes inactive. Send a fake XFocusOut + // event to convince Qt that we no longer are active. We will + // receive extra Qt FocusOut events but we do not care. + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = qt_xdisplay(); + ev.xfocus.type = XFocusOut; + ev.xfocus.window = w->topLevelWidget()->winId(); + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + qApp->x11ProcessEvent( &ev ); + } + break; + case XEMBED_FOCUS_IN: + // L0680: Embedding application gives us the focus. + { + // L0681: Search saved focus widget. + QWidget* focusCurrent = 0; + QGuardedPtr* fw = focusMap->find( w->topLevelWidget() ); + if ( fw ) { + focusCurrent = *fw; + // L0682: Remove it from the map + focusMap->remove( w->topLevelWidget() ); + } + switch ( detail ) { + case XEMBED_FOCUS_CURRENT: + // L0683: Set focus on saved focus widget + if ( focusCurrent ) + focusCurrent->setFocus(); + else if ( !w->topLevelWidget()->focusWidget() ) + w->topLevelWidget()->setFocus(); + break; + case XEMBED_FOCUS_FIRST: + { + // L0684: Search first widget in tab chain + QFocusEvent::setReason( QFocusEvent::Tab ); + w->topLevelWidget()->setFocus(); + ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(true); + QFocusEvent::resetReason(); + } + break; + case XEMBED_FOCUS_LAST: + { + // L0686: Search last widget in tab chain + QFocusEvent::setReason( QFocusEvent::Backtab ); + w->topLevelWidget()->setFocus(); + ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(false); + QFocusEvent::resetReason(); + } + break; + default: + break; + } + } + break; + case XEMBED_FOCUS_OUT: + // L0688: Embedding application takes the focus away + // We first record what the focus widget was + // and clear the Qt focus. + if ( w->topLevelWidget()->focusWidget() ) { + focusMap->insert( w->topLevelWidget(), + new QGuardedPtr(w->topLevelWidget()->focusWidget() ) ); + w->topLevelWidget()->focusWidget()->clearFocus(); + } + break; + default: + break; + } + } else if ( e->xclient.format == 32 && e->xclient.message_type ) { + if ( e->xclient.message_type == qt_wm_protocols ) { + QWidget* w = QWidget::find( e->xclient.window ); + if ( !w ) + break; + // L0690: This is for the embedding side! + // See L0902 for more information about the focus proxy. + // Window manager may send WM_TAKE_FOCUS messages to the + // embedding application to indicate that it becomes active. + // But this also suggests that the window manager has + // changed the X11 focus. We want to make sure it goes + // to the focus proxy window eventually. + Atom a = e->xclient.data.l[0]; + if ( a == qt_wm_take_focus ) { + // L0695: update Qt message time variable + if ( (ulong) e->xclient.data.l[1] > qt_x_time ) + qt_x_time = e->xclient.data.l[1]; + // L0696: There is no problem when the window is not active. + // Qt will generate a WindowActivate event that will + // do the job (L1310). This does not happen if the + // window is already active. So we simulate it. + if ( w->isActiveWindow() ) { + QEvent e( QEvent::WindowActivate ); + QApplication::sendEvent( w, &e ); + } + } + } + } + break; + default: + break; + } + // L0698: The next x11 filter + if ( oldFilter ) + return oldFilter( e ); + // L0699: Otherwise process the event as usual. + return false; +} + + + +// L0700: Install the xembed filters in both client and embedder sides. +// This function is called automatically when using +// embedClientIntoWindow() or creating an instance of QXEmbed You may +// have to call it manually for a client when using embedder-side +// embedding, though. +void QXEmbed::initialize() +{ + static bool is_initialized = false; + if ( is_initialized ) + return; + + // L0710: Atom used by the XEMBED protocol. + xembed = XInternAtom( qt_xdisplay(), "_XEMBED", false ); + // L0720: Install low level filter for X11 events (L0650) + oldFilter = qt_set_x11_event_filter( qxembed_x11_event_filter ); + // L0730: See L0610 for an explanation about focusMap. + focusMap = new QPtrDict >; + focusMap->setAutoDelete( true ); + // L0740: Create client side application wide event filter (L0610) + filter = new QXEmbedAppFilter; + + is_initialized = true; +} + + + + + +// ------------------------------------------------------------ +// L0800: MOST OF WHAT FOLLOWS CONCERNS THE EMBEDDER SIDE. +// Things that happen inside a Qt application that contain +// a QXEmbed widget for embedding other applications. +// This applies to both the XEMBED and XPLAIN protocols. +// Deviations are commented below. + + + +// L0810: Class QXEmbed. +// A QXEmbed widget serves as an embedder that can manage one single +// embedded X-window. These so-called client windows can be arbitrary +// Qt or non Qt applications. There are two different ways of using +// QXEmbed, from the client side or from the embedder's side. + + +// L0900: Constructs a xembed widget. +QXEmbed::QXEmbed(QWidget *parent, const char *name, WFlags f) + : QWidget(parent, name, f) +{ + // L0901: Create private data. See L0100. + d = new QXEmbedData; + // L0902: Create focus proxy widget. See XEmbed specification. + // Each QXEmbed widget has a focus proxy window. Every single + // QXEmbed widget tries to force its focus proxy window onto the + // whole embedding application. They compete between themselves and + // against Qt (L0690, L0914, L1040, L1310, L1510, L1580). + // This would be much simpler if implemented within Qt. + d->focusProxy = new QWidget( topLevelWidget(), "xembed_focus" ); + d->focusProxy->setGeometry( -1, -1, 1, 1 ); + d->focusProxy->show(); + // make sure it's shown - for XSetInputFocus + QApplication::sendPostedEvents( d->focusProxy, 0 ); + // L0903: Install the client side event filters + // because they also provide services for the embedder side + // See L0660, L0671, L0685. + initialize(); + window = 0; + setFocusPolicy(StrongFocus); + setKeyCompression( false ); + + // L0910: Trick Qt to create extraData(); + (void) topData(); + + // L0912: We are mostly interested in SubstructureNotify + // This is sent when something happens to the children of + // the X11 window associated with the QXEmbed widget. + XSelectInput(qt_xdisplay(), winId(), + KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask | + KeymapStateMask | + ButtonMotionMask | + PointerMotionMask | // may need this, too + EnterWindowMask | LeaveWindowMask | + FocusChangeMask | + ExposureMask | + StructureNotifyMask | + SubstructureRedirectMask | + SubstructureNotifyMask + ); + // L0913: all application events pass through eventFilter(). + // This is mostly used to force the X11 focus on the + // proxy focus window. See L1300. + topLevelWidget()->installEventFilter( this ); + qApp->installEventFilter( this ); + + // L0914: Start moving the X11 focus on the focus proxy window. + // See L1581 to know why we do not use isActiveWindow(). + if ( qApp->activeWindow() == topLevelWidget() ) + if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded ) + XSetInputFocus( qt_xdisplay(), d->focusProxy->winId(), + RevertToParent, qt_x_time ); + // L0915: ??? [drag&drop?] + setAcceptDrops( true ); +} + +// L1000: Destructor must dispose of the embedded client window. +QXEmbed::~QXEmbed() +{ + // L1010: Make sure no pointer grab is left. + if ( d && d->xgrab) + XUngrabButton( qt_xdisplay(), AnyButton, AnyModifier, winId() ); + if ( window && ( autoDelete() || !d->xplain )) + { + // L1021: Hide the window and safely reparent it into the root, + // otherwise it would be destroyed by X11 together + // with this QXEmbed's window. +#if 0 +// TODO: The proper XEmbed way would be to unmap the window, and the embedded +// app would detect the embedding has ended, and do whatever it finds appropriate. +// However, QXEmbed currently doesn't provide support for this detection, +// so for the time being, it's better to leave the window mapped as toplevel window. +// This will be ever more complicated with the systray windows, as the simple API +// for them (KWin::setSystemTrayWindowFor()) doesn't make it possible to detect +// themselves they have been released from systray, but KWin requires them +// to be visible to allow next Kicker instance to swallow them. +// See also below the L1022 comment. +// XUnmapWindow( qt_xdisplay(), window ); +#else + if( autoDelete()) + XUnmapWindow( qt_xdisplay(), window ); +#endif + XReparentWindow(qt_xdisplay(), window, qt_xrootwin(), 0, 0); + if( !d->xplain ) + XRemoveFromSaveSet( qt_xdisplay(), window ); + if( d->mapAfterRelease ) + XMapWindow( qt_xdisplay(), window ); + XSync(qt_xdisplay(), false); + // L1022: Send the WM_DELETE_WINDOW message + if( autoDelete() /*&& d->xplain*/ ) + // This sendDelete should only apply to XPLAIN. + // XEMBED apps are supposed to detect when the embedding ends. + // ??? [We do not do this detection yet! + // So we sendDelete() instead.] + sendDelete(); + } + window = 0; + // L01040: Our focus proxy window will be destroyed as well. + // Make sure that the X11 focus is not lost in the process. + Window focus; + int revert; + XGetInputFocus( qt_xdisplay(), &focus, &revert ); + if( focus == d->focusProxy->winId()) + XSetInputFocus( qt_xdisplay(), topLevelWidget()->winId(), RevertToParent, qt_x_time ); + // L01045: Delete our private data. + delete d; +} + + +// L1050: Sends a WM_DELETE_WINDOW message to the embedded window. This is +// what typically happens when you click on the close button of a +// window manager decoration. +void QXEmbed::sendDelete( void ) +{ + if (window) + { + sendClientMessage(window, qt_wm_protocols, qt_wm_delete_window); + XFlush( qt_xdisplay() ); + } +} + +// L1100: Sets the protocol used for embedding windows. +// This function must be called before embedding a window. +// Protocol XEMBED provides maximal functionality (focus, tabs, etc) +// but requires explicit cooperation from the embedded window. +// Protocol XPLAIN provides maximal compatibility with +// embedded applications that do not support the XEMBED protocol. +// The default is XEMBED. +void QXEmbed::setProtocol( Protocol proto ) +{ + if (!window) { + d->xplain = false; + if (proto == XPLAIN) + d->xplain = true; + } +} + +// L1150: Returns the protocol used for embedding the current window. +QXEmbed::Protocol QXEmbed::protocol() +{ + if (d->xplain) + return XPLAIN; + return XEMBED; +} + + +// L1200: QXEmbed widget size changes: resize embedded window. +void QXEmbed::resizeEvent(QResizeEvent*) +{ + if (window) + XResizeWindow(qt_xdisplay(), window, width(), height()); +} + +// L1250: QXEmbed widget is shown: make sure embedded window is visible. +void QXEmbed::showEvent(QShowEvent*) +{ + if (window) + XMapRaised(qt_xdisplay(), window); +} + + +// L1300: This event filter sees all application events (L0913). +bool QXEmbed::eventFilter( QObject *o, QEvent * e) +{ + + switch ( e->type() ) { + case QEvent::WindowActivate: + if ( o == topLevelWidget() ) { + // L1310: Qt thinks the application window has just been activated. + // Make sure the X11 focus is on the focus proxy window. See L0686. + if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded ) + if (! hasFocus() ) + XSetInputFocus( qt_xdisplay(), d->focusProxy->winId(), + RevertToParent, qt_x_time ); + if (d->xplain) + // L1311: Activation has changed. Grab state might change. See L2800. + checkGrab(); + else + // L1312: Let the client know that we just became active + sendXEmbedMessage( window, XEMBED_WINDOW_ACTIVATE ); + } + break; + case QEvent::WindowDeactivate: + if ( o == topLevelWidget() ) { + if (d->xplain) + // L1321: Activation has changed. Grab state might change. See L2800. + checkGrab(); + else + // L1322: Let the client know that we are no longer active + sendXEmbedMessage( window, XEMBED_WINDOW_DEACTIVATE ); + } + break; + case QEvent::Move: + { + QWidget* pos = this; + while( pos != o && pos != topLevelWidget()) + pos = pos->parentWidget(); + if( pos == o ) { + // L1390: Send fake configure notify events whenever the + // global position of the client changes. See L2900. + QPoint globalPos = mapToGlobal(QPoint(0,0)); + if (globalPos != d->lastPos) { + d->lastPos = globalPos; + sendSyntheticConfigureNotifyEvent(); + } + } + } + break; + default: + break; + } + return false; +} + +// L1350: ??? [why this?] +bool QXEmbed::event( QEvent * e) +{ + return QWidget::event( e ); +} + +// L1400: Forward keypress event to the client +// Receiving a Qt key event indicates that +// the QXEmbed object has the Qt focus. +// The X11 event that caused the Qt key event +// must be forwarded to the client. +// See L0660. +void QXEmbed::keyPressEvent( QKeyEvent *) +{ + if (!window) + return; + last_key_event.window = window; + XSendEvent(qt_xdisplay(), window, false, KeyPressMask, (XEvent*)&last_key_event); + +} + +// L1450: Forward keyrelease event to the client. +// See comment L1400. +void QXEmbed::keyReleaseEvent( QKeyEvent *) +{ + if (!window) + return; + last_key_event.window = window; + XSendEvent(qt_xdisplay(), window, false, KeyReleaseMask, (XEvent*)&last_key_event); +} + +// L1500: Handle Qt focus in event. +void QXEmbed::focusInEvent( QFocusEvent * e ){ + if (!window) + return; + // L1510: This is a good time to set the X11 focus on the focus proxy window. + // Except if the the embedding application itself is embedded into another. + if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded ) + if ( qApp->activeWindow() == topLevelWidget() ) + // L1511: Alter X focus only when window is active. + // This is dual safety here because FocusIn implies this. + // But see L1581 for an example where this really matters. + XSetInputFocus( qt_xdisplay(), d->focusProxy->winId(), + RevertToParent, qt_x_time ); + if (d->xplain) { + // L1520: Qt focus has changed. Grab state might change. See L2800. + checkGrab(); + // L1521: Window managers activate applications by setting the X11 focus. + // We cannot do this (see L1510) but we can send a fake focus event + // and forward the X11 key events ourselves (see L1400, L1450). + sendFocusMessage(window, XFocusIn, NotifyNormal, NotifyPointer ); + } else { + // L1530: No need for fake events with XEMBED. + // Just inform the client. It knows what to do. + int detail = XEMBED_FOCUS_CURRENT; + // L1531: When the focus change is caused by the tab key, + // the client must select the first (or last) widget of + // its own tab chain. + if ( e->reason() == QFocusEvent::Tab ) + detail = XEMBED_FOCUS_FIRST; + else if ( e->reason() == QFocusEvent::Backtab ) + detail = XEMBED_FOCUS_LAST; + sendXEmbedMessage( window, XEMBED_FOCUS_IN, detail); + } +} + +// L1550: Handle Qt focus out event. +void QXEmbed::focusOutEvent( QFocusEvent * ){ + if (!window) + return; + if (d->xplain) { + // L1560: Qt focus has changed. Grab state might change. See L2800. + checkGrab(); + // L1561: Send fake focus out message. See L1521. + sendFocusMessage(window, XFocusOut, NotifyNormal, NotifyPointer ); + } else { + // L1570: Send XEMBED focus out message. See L1531. + sendXEmbedMessage( window, XEMBED_FOCUS_OUT ); + } + // L1580: The QXEmbed object might loose the focus because its + // toplevel window looses the X11 focus and is no longer active, + // or simply because the Qt focus has been moved to another widget. + // In the latter case only, we want to make sure that the X11 focus + // is properly set to the X11 focus widget. We do this because + // the client application might have moved the X11 focus after + // receiving the fake focus messages. + if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded ) + if ( qApp->activeWindow() == topLevelWidget() ) + // L1581: Alter X focus only when window is active. + // The test above is not the same as isActiveWindow(). + // Function isActiveWindow() also returns true when a modal + // dialog child of this window is active. + XSetInputFocus( qt_xdisplay(), d->focusProxy->winId(), + RevertToParent, qt_x_time ); +} + + +// L1600: Helper for QXEmbed::embed() +// Check whether a window is in withdrawn state. +static bool wstate_withdrawn( WId winid ) +{ + Atom type; + int format; + unsigned long length, after; + unsigned char *data; + int r = XGetWindowProperty( qt_xdisplay(), winid, qt_wm_state, 0, 2, + false, AnyPropertyType, &type, &format, + &length, &after, &data ); + bool withdrawn = true; + // L1610: Non managed windows have no WM_STATE property. + // Returning true ensures that the loop L1711 stops. + if ( r == Success && data && format == 32 ) { + Q_UINT32 *wstate = (Q_UINT32*)data; + withdrawn = (*wstate == WithdrawnState ); + XFree( (char *)data ); + } + return withdrawn; +} + +// L1650: Helper for QXEmbed::embed() +// Get the X11 id of the parent window. +static int get_parent(WId winid, Window *out_parent) +{ + Window root, *children=0; + unsigned int nchildren; + int st = XQueryTree(qt_xdisplay(), winid, &root, out_parent, &children, &nchildren); + if (st && children) + XFree(children); + return st; +} + +// L1700: Embeds the window w into this QXEmbed widget. +// See doc in qxembed.h. +void QXEmbed::embed(WId w) +{ +/* kdDebug() << "*** Embed " << w << " into " << winId() << ". window=" << window << endl;*/ + if (!w) + return; + // L1701: The has_window variable prevents embedding a same window twice. + // ??? [what happens if one embed two windows into the same QXEmbed?] + bool has_window = (w == window); + window = w; + if ( !has_window ) { + //KXErrorHandler errhandler; // make X BadWindow errors silent + // L1710: Try hard to withdraw the window. + // This makes sure that the window manager will + // no longer try to manage this window. + if ( !wstate_withdrawn(window) ) { + XWithdrawWindow(qt_xdisplay(), window, qt_xscreen()); + QApplication::flushX(); + // L1711: See L1610 + while (!wstate_withdrawn(window)) + USLEEP(1000); + } + // L1710: It would be sufficient in principle to reparent + // window w into winId(). Everything else happens in L2020. + // The following code might be useful when the X11 server takes + // time to create the embedded application main window. + Window parent = 0; + get_parent(w, &parent); +/* kdDebug() << QString("> before reparent: parent=0x%1").arg(parent,0,16) << endl;*/ + for (int i = 0; i < 50; i++) { + // this is done once more when finishing embedding, but it's done also here + // just in case we crash before reaching that place + if( !d->xplain ) + XAddToSaveSet( qt_xdisplay(), w ); + XReparentWindow(qt_xdisplay(), w, winId(), 0, 0); + if (get_parent(w, &parent) && parent == winId()) { +/* kdDebug() << QString("> Loop %1: ").arg(i) + << QString("> reparent of 0x%1").arg(w,0,16) + << QString(" into 0x%1").arg(winId(),0,16) + << QString(" successful") << endl;*/ + break; + } +/* kdDebug() << QString("> Loop %1: ").arg(i) + << QString("> reparent of 0x%1").arg(w,0,16) + << QString(" into 0x%1").arg(winId(),0,16) + << QString(" failed") << endl;*/ + USLEEP(1000); + } + if( parent != winId()) // failed + window = 0; + } +} + + +// L1800: Returns the window identifier of the embedded window +WId QXEmbed::embeddedWinId() const +{ + return window; +} + + +// L1900: Control Qt tab focus management. +// See Qt documentation. +bool QXEmbed::focusNextPrevChild( bool next ) +{ + if ( window ) + // L1901: Return false when there is an embedded window + // When the user presses TAB, Qt will not change + // the focus and pass the TAB key events to the QXEmbed widget. + // These key events will be forwarded to the client (L1400, L1450) + // who eventually will manage the tab focus (L0620) and possible + // instruct us to call QWidget::focusNextPrevChild (L2081). + return false; + else + // L1920: Default behavior otherwise. + return QWidget::focusNextPrevChild( next ); +} + + +// L2000: Filter for X11 events sent to the QXEmbed window. +bool QXEmbed::x11Event( XEvent* e) +{ + switch ( e->type ) { + case DestroyNotify: + if ( e->xdestroywindow.window == window ) { + // L2005: Client window is being destroyed. + window = 0; + windowChanged( window ); + emit embeddedWindowDestroyed(); + } + break; + case ReparentNotify: + if ( e->xreparent.window == d->focusProxy->winId() ) + break; // ignore proxy + if ( window && e->xreparent.window == window && + e->xreparent.parent != winId() ) { + // L2010: We lost the window + window = 0; + windowChanged( window ); + emit embeddedWindowDestroyed(); + // L2011: Remove window from save set + // ??? [not sure it is good to touch this window since + // someone else has taken control of it already.] + if( !d->xplain ) + XRemoveFromSaveSet( qt_xdisplay(), window ); + } else if ( e->xreparent.parent == winId()){ + // L2020: We got a window. Complete the embedding process. + window = e->xreparent.window; + // only XEMBED apps can survive crash, + // see http://lists.kde.org/?l=kfm-devel&m=106752026501968&w=2 + if( !d->xplain ) + XAddToSaveSet( qt_xdisplay(), window ); + XResizeWindow(qt_xdisplay(), window, width(), height()); + XMapRaised(qt_xdisplay(), window); + // L2024: see L2900. + sendSyntheticConfigureNotifyEvent(); + // L2025: ??? [any idea about drag&drop?] + extraData()->xDndProxy = window; + if ( parent() ) { + // L2030: embedded window might have new size requirements. + // see L2500, L2520, L2550. + QEvent * layoutHint = new QEvent( QEvent::LayoutHint ); + QApplication::postEvent( parent(), layoutHint ); + } + windowChanged( window ); + if (d->xplain) { + // L2040: Activation has changed. Grab state might change. See L2800. + checkGrab(); + if ( hasFocus() ) + // L2041: Send fake focus message to inform the client. See L1521. + sendFocusMessage(window, XFocusIn, NotifyNormal, NotifyPointer ); + } else { + // L2050: Send XEMBED messages (see L0670, L1312, L1322, L1530) + sendXEmbedMessage( window, XEMBED_EMBEDDED_NOTIFY, 0, (long) winId() ); + if (isActiveWindow()) + sendXEmbedMessage( window, XEMBED_WINDOW_ACTIVATE); + else + sendXEmbedMessage( window, XEMBED_WINDOW_DEACTIVATE); + if ( hasFocus() ) + sendXEmbedMessage( window, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT ); + } + } + break; + case ButtonPress: + if (d->xplain && d->xgrab) { + // L2060: The passive grab has intercepted a mouse click + // in the embedded client window. Take the focus. + QFocusEvent::setReason( QFocusEvent::Mouse ); + setFocus(); + QFocusEvent::resetReason(); + // L2064: Resume X11 event processing. + XAllowEvents(qt_xdisplay(), ReplayPointer, CurrentTime); + // L2065: Qt should not know about this. + return true; + } + break; + case ButtonRelease: + if (d->xplain && d->xgrab) { + // L2064: Resume X11 event processing after passive grab (see L2060) + XAllowEvents(qt_xdisplay(), SyncPointer, CurrentTime); + return true; + } + break; + case MapRequest: + // L2070: Behave like a window manager. + if ( window && e->xmaprequest.window == window ) + XMapRaised(qt_xdisplay(), window ); + break; + case ClientMessage: + // L2080: This is where the QXEmbed object receives XEMBED + // messaged from the client application. + if ( e->xclient.format == 32 && e->xclient.message_type == xembed ) { + long message = e->xclient.data.l[1]; + switch ( message ) { + // L2081: Tab focus management. It is very important to call the + // focusNextPrevChild() defined by QWidget (not QXEmbed). + // See L1901. + case XEMBED_FOCUS_NEXT: + QWidget::focusNextPrevChild( true ); + break; + case XEMBED_FOCUS_PREV: + QWidget::focusNextPrevChild( false ); + break; + // L2085: The client asks for the focus. + case XEMBED_REQUEST_FOCUS: + if( ((QPublicWidget*)topLevelWidget())->topData()->embedded ) { + WId window = ((QPublicWidget*)topLevelWidget())->topData()->parentWinId; + sendXEmbedMessage( window, XEMBED_REQUEST_FOCUS ); + } else { + QFocusEvent::setReason( QFocusEvent::Mouse ); + setFocus(); + QFocusEvent::resetReason(); + } + break; + default: + break; + } + } + break; + + case ConfigureRequest: + // L2090: Client wants to change its geometry. + // Just inform it that nothing has changed. + if (e->xconfigurerequest.window == window) + { + sendSyntheticConfigureNotifyEvent(); + } + break; + case MotionNotify: + // fall through, workaround for Qt 3.0 < 3.0.3 + case EnterNotify: + // L2095: See L2200. + if ( QWhatsThis::inWhatsThisMode() ) + enterWhatsThisMode(); + break; + default: + break; + } + return false; +} + + +// L2200: Try to handle Qt's "what's this" mode. Broken. +// "temporary, fix in Qt (Matthias, Mon Jul 17 15:20:55 CEST 2000" +void QXEmbed::enterWhatsThisMode() +{ + // L2210: When the what-s-this pointer enters the embedded window (L2095) + // cancel what-s-this mode, and use a non stantard _NET_WM_ message + // to instruct the embedded client to enter the "what's this" mode. + // This works only one way... + QWhatsThis::leaveWhatsThisMode(); + if ( !context_help ) + context_help = XInternAtom( x11Display(), "_NET_WM_CONTEXT_HELP", false ); + sendClientMessage(window , qt_wm_protocols, context_help ); +} + + +// L2300: indicates that the embedded window has been changed. +void QXEmbed::windowChanged( WId ) +{ +} + + +// L2400: Utility function for clients that embed themselves. +// This is client side code. +bool QXEmbed::processClientCmdline( QWidget* client, int& argc, char ** argv ) +{ + int myargc = argc; + WId window = 0; + int i, j; + + j = 1; + for ( i=1; iwinId(), window, 0, 0); + // L2451: These two lines are redundant. See L0680. + ((QXEmbed*)client)->topData()->embedded = true; + ((QXEmbed*)client)->topData()->parentWinId = window; + // L2452: This seems redundant because L2020 maps the window. + // But calling show() might also set Qt internal flags. + client->show(); +} + + + +// L2500: Specifies that this widget can use additional space, +// and that it can survive on less than sizeHint(). +QSizePolicy QXEmbed::sizePolicy() const +{ + return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); +} + + +// L2520: Returns a size sufficient for the embedded window +QSize QXEmbed::sizeHint() const +{ + return minimumSizeHint(); +} + +// L2550: Returns the minimum size specified by the embedded window. +QSize QXEmbed::minimumSizeHint() const +{ + int minw = 0; + int minh = 0; + if ( window ) { + XSizeHints size; + long msize; + if (XGetWMNormalHints(qt_xdisplay(), window, &size, &msize) + && ( size.flags & PMinSize) ) { + minw = size.min_width; + minh = size.min_height; + } + } + + return QSize( minw, minh ); +} + +// L2600: Tells what shoud be done with the embedded window when +// the embedding window is destroyed. +void QXEmbed::setAutoDelete( bool b) +{ + d->autoDelete = b; +} + +// L2650: See L2600. +bool QXEmbed::autoDelete() const +{ + return d->autoDelete; +} + +// L2700: See L2200. +bool QXEmbed::customWhatsThis() const +{ + return true; +} + +// L2800: When using the XPLAIN protocol, this function maintains +// a passive button grab when (1) the application is active +// and (2) the Qt focus is not on the QXEmbed. This passive +// grab intercepts button clicks in the client window and +// give us chance to request the Qt focus (L2060). +void QXEmbed::checkGrab() +{ + if (d->xplain && isActiveWindow() && !hasFocus()) { + if (! d->xgrab) + XGrabButton(qt_xdisplay(), AnyButton, AnyModifier, winId(), + false, ButtonPressMask, GrabModeSync, GrabModeAsync, + None, None ); + d->xgrab = true; + } else { + if (d->xgrab) + XUngrabButton( qt_xdisplay(), AnyButton, AnyModifier, winId() ); + d->xgrab = false; + } +} + +// L2900: This sends fake configure notify events to inform +// the client about its window geometry. See L1390, L2024 and L2090. +void QXEmbed::sendSyntheticConfigureNotifyEvent() +{ + // L2910: It seems that the x and y coordinates are global. + // But this is what ICCCM section 4.1.5 wants. + // See http://lists.kde.org/?l=kfm-devel&m=107090222032378 + QPoint globalPos = mapToGlobal(QPoint(0,0)); + if (window) { + XConfigureEvent c; + memset(&c, 0, sizeof(c)); + c.type = ConfigureNotify; + c.display = qt_xdisplay(); + c.send_event = True; + c.event = window; + c.window = winId(); + c.x = globalPos.x(); + c.y = globalPos.y(); + c.width = width(); + c.height = height(); + c.border_width = 0; + c.above = None; + c.override_redirect = 0; + XSendEvent( qt_xdisplay(), c.event, true, StructureNotifyMask, (XEvent*)&c ); + } +} + +// L3000: One should not call QWidget::reparent after embedding a window. +void QXEmbed::reparent( QWidget * parent, WFlags f, const QPoint & p, bool showIt ) +{ + // QWidget::reparent() destroys the old X Window for the widget, and + // creates a new one, thus QXEmbed after reparenting is no longer the + // parent of the embedded window. I think reparenting of QXEmbed can be + // done only by a mistake, so just complain. + Q_ASSERT( !window ); + QWidget::reparent( parent, f, p, showIt ); +} + +// for KDE +#include "qxembed.moc" +#endif // Q_WS_X11 diff --git a/src/widgets/rename_dialog.cpp b/src/widgets/rename_dialog.cpp index 440fb403a8..05e66e43f9 100644 --- a/src/widgets/rename_dialog.cpp +++ b/src/widgets/rename_dialog.cpp @@ -1,8 +1,9 @@ /* * rename_dialog.cpp - implementation of dialog for renaming something * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/side_bar_widget.cpp b/src/widgets/side_bar_widget.cpp index b27489b2c0..9151f69894 100644 --- a/src/widgets/side_bar_widget.cpp +++ b/src/widgets/side_bar_widget.cpp @@ -1,8 +1,9 @@ /* * side_bar_widget.cpp - implementation of base-widget for side-bar * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/tab_bar.cpp b/src/widgets/tab_bar.cpp index 0346dfd95e..0edc28dd7b 100644 --- a/src/widgets/tab_bar.cpp +++ b/src/widgets/tab_bar.cpp @@ -1,8 +1,9 @@ /* * tab_bar.cpp - implementation of tab-bar * - * Linux MultiMedia Studio * Copyright (c) 2004-2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/tab_widget.cpp b/src/widgets/tab_widget.cpp index d2cedf0411..1cb14b0248 100644 --- a/src/widgets/tab_widget.cpp +++ b/src/widgets/tab_widget.cpp @@ -1,8 +1,9 @@ /* * tabwidget.cpp - tabwidget for LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index b53730c818..2bc7fad9a3 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -1,10 +1,9 @@ /* * tempo_sync_knob.h - adds bpm to ms conversion for knob class * - * This file is derived from the knob-widget by Tobias Doerffel - * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Danny McRae + * Copyright (c) 2005 Danny McRae + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -60,8 +59,8 @@ -tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, const QString & _name, - float _scale ) : +tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, + const QString & _name, float _scale ) : knob( _knob_num, _parent, _name ), m_tempoSyncMode( NO_SYNC ), m_scale( _scale ), @@ -115,9 +114,10 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) int menuId; menuId = syncMenu->addAction( embed::getIconPixmap( "note_none" ), tr( "No Sync" ), - this, SLOT( setTempoSync( int ) ) ); + this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) NO_SYNC ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), + menuId = syncMenu->addAction( embed::getIconPixmap( + "note_double_whole" ), tr( "Eight beats" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) DOUBLE_WHOLE_NOTE ); @@ -135,18 +135,20 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) syncMenu->setItemParameter( menuId, ( int ) QUARTER_NOTE ); menuId = syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), tr( "8th note" ), - this, SLOT( setTempoSync( int ) ) ); + this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) EIGHTH_NOTE ); menuId = syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), tr( "16th note" ), - this, SLOT( setTempoSync( int ) ) ); + this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) SIXTEENTH_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), + menuId = syncMenu->addAction( embed::getIconPixmap( + "note_thirtysecond" ), tr( "32nd note" ), - this, SLOT( setTempoSync( int ) ) ); + this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) THIRTYSECOND_NOTE ); - contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription, syncMenu ); + contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription, + syncMenu ); contextMenu.addSeparator(); contextMenu.addAction( tr( "Connect to MIDI-device" ), this, @@ -201,42 +203,57 @@ void tempoSyncKnob::calculateTempoSyncTime( int _bpm ) switch( m_tempoSyncMode ) { case DOUBLE_WHOLE_NOTE: - m_tempoSyncDescription = tr( "Synced to Eight Beats" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_double_whole" ); + m_tempoSyncDescription = tr( + "Synced to Eight Beats" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_double_whole" ); conversionFactor = 0.125; break; case WHOLE_NOTE: - m_tempoSyncDescription = tr( "Synced to Whole Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_whole" ); + m_tempoSyncDescription = tr( + "Synced to Whole Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_whole" ); conversionFactor = 0.25; break; case HALF_NOTE: - m_tempoSyncDescription = tr( "Synced to Half Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_half" ); + m_tempoSyncDescription = tr( + "Synced to Half Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_half" ); conversionFactor = 0.5; break; case QUARTER_NOTE: - m_tempoSyncDescription = tr( "Synced to Quarter Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_quarter" ); + m_tempoSyncDescription = tr( + "Synced to Quarter Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_quarter" ); conversionFactor = 1.0; break; case EIGHTH_NOTE: - m_tempoSyncDescription = tr( "Synced to 8th Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_eighth" ); + m_tempoSyncDescription = tr( + "Synced to 8th Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_eighth" ); conversionFactor = 2.0; break; case SIXTEENTH_NOTE: - m_tempoSyncDescription = tr( "Synced to 16th Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_sixteenth" ); + m_tempoSyncDescription = tr( + "Synced to 16th Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_sixteenth" ); conversionFactor = 4.0; break; case THIRTYSECOND_NOTE: - m_tempoSyncDescription = tr( "Synced to 32nd Note" ); - m_tempoSyncIcon = embed::getIconPixmap( "note_thirtysecond" ); + m_tempoSyncDescription = tr( + "Synced to 32nd Note" ); + m_tempoSyncIcon = embed::getIconPixmap( + "note_thirtysecond" ); conversionFactor = 8.0; break; default: - printf( "tempoSyncKnob::calculateTempoSyncTime: invalid tempoSyncMode" ); + printf( "tempoSyncKnob::calculateTempoSyncTime" + ": invalid tempoSyncMode" ); break; } setValue( 60000.0 / ( _bpm * conversionFactor * m_scale ), diff --git a/src/widgets/text_float.cpp b/src/widgets/text_float.cpp index 2f934be499..eec6ed4dfd 100644 --- a/src/widgets/text_float.cpp +++ b/src/widgets/text_float.cpp @@ -1,8 +1,9 @@ /* * text_float.cpp - class textFloat, a floating text-label * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/tooltip.cpp b/src/widgets/tooltip.cpp index 9f7030e95e..b78ebe76c4 100644 --- a/src/widgets/tooltip.cpp +++ b/src/widgets/tooltip.cpp @@ -1,8 +1,9 @@ /* * tooltip.cpp - namespace toolTip, a tooltip-wrapper for LMMS * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/widgets/visualization_widget.cpp b/src/widgets/visualization_widget.cpp index 23b04976aa..5fe63165f2 100644 --- a/src/widgets/visualization_widget.cpp +++ b/src/widgets/visualization_widget.cpp @@ -1,8 +1,9 @@ /* - * visualization_widget.cpp - widget for visualization of waves + * visualization_widget.cpp - widget for visualization of sound-data * - * Linux MultiMedia Studio - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2005 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -64,13 +65,14 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); m_buffer = bufferAllocator::alloc( frames ); - for( Uint32 frame = 0; frame < frames; ++frame ) + mixer::inst()->clearAudioBuffer( m_buffer, frames ); +/* for( Uint32 frame = 0; frame < frames; ++frame ) { for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) { m_buffer[frame][chnl] = 0.0f; } - } + }*/ setFixedSize( s_background.width(), s_background.height() );