[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/kmid/src
From:       Pedro Lopez-Cabanillas <pedro.lopez.cabanillas () gmail ! com>
Date:       2010-07-22 13:36:38
Message-ID: 20100722133638.7860AAC7AB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1153053 by pedrol:

kmid_part: fixes and documentation

 M  +8 -7      kmid_part.cpp  
 M  +264 -18   kmid_part.h  
 M  +90 -12    kmid_partview.h  


--- trunk/extragear/multimedia/kmid/src/kmid_part.cpp #1153052:1153053
@@ -55,8 +55,8 @@
 class KMidPart::KMidPartPrivate {
 public:
     KMidPartPrivate(KMidPart *parent, QWidget *parentWidget) :
+        q(parent),
         m_parentWidget(parentWidget),
-        m_adaptor(new KMidPartAdaptor(parent)),
         m_view(0),
         m_loader(0),
         m_currentBackend(0),
@@ -64,7 +64,8 @@
         m_midiout(0),
         m_settings(new KMid::Settings),
         m_mapper(new KMid::MidiMapper),
-        m_autoStart(true)
+        m_autoStart(true),
+        m_volfactor(1.0)
     {
         if (parentWidget != 0)
             m_view = new KMidPartView(parentWidget);
@@ -75,8 +76,8 @@
         delete m_settings;
     }
 
+    KMidPart *q;
     QWidget *m_parentWidget;
-    KMidPartAdaptor *m_adaptor;
     KMidPartView *m_view;
     KMid::BackendLoader *m_loader;
     KMid::Backend *m_currentBackend;
@@ -91,6 +92,7 @@
     QList<MidiBackend> m_backends;
     QString m_currentBackendLibrary;
     bool m_autoStart;
+    double m_volfactor;
 };
 
 KMidPart::KMidPart( QWidget *parentWidget, QObject *parent, const QVariantList& /*args*/ )
@@ -98,6 +100,7 @@
       d(new KMidPartPrivate(this, parentWidget))
 {
     setComponentData( KMidPartFactory::componentData() );
+    (void) new KMidPartAdaptor(this);
     QDBusConnection::sessionBus().registerObject(QLatin1String("/KMidPart"), this);
     setupActions();
     setXMLFile("kmid_part.rc");
@@ -515,13 +518,13 @@
 
 void KMidPart::setVolumeFactor(double f)
 {
+    d->m_volfactor = f;
     if (d->m_midiout != 0)
         d->m_midiout->setVolume(-1, f);
 }
 
 void KMidPart::setTranspose(int t)
 {
-    kDebug() << t;
     if (d->m_midiout != 0)
         d->m_midiout->setPitchShift(t);
 }
@@ -535,9 +538,7 @@
 
 double KMidPart::volumeFactor()
 {
-    if (d->m_midiout != 0)
-        return d->m_midiout->volume(-1);
-    return 1.0;
+    return d->m_volfactor;
 }
 
 int KMidPart::transpose()
--- trunk/extragear/multimedia/kmid/src/kmid_part.h #1153052:1153053
@@ -20,8 +20,16 @@
 #ifndef KMID_PART_H
 #define KMID_PART_H
 
-#include <KDE/KMediaPlayer/Player>
+#include <KMediaPlayer/Player>
 
+#ifndef KMIDPART_EXPORT
+# if defined(kmid_part_EXPORTS)
+#  define KMIDPART_EXPORT KDE_EXPORT
+# else
+#  define KMIDPART_EXPORT KDE_IMPORT
+# endif
+#endif
+
 class KAboutData;
 
 namespace KMid {
@@ -30,13 +38,18 @@
 using namespace KMid;
 
 /**
- * KMid Part.
+ * KMidPart is an implementation of the KMediaPlayer::Player interface for
+ * the MIDI/Karaoke player KPart component.
  *
- * @short Main Part
+ * This KPart provides a minimal user interface and the basic functionality of
+ * the KMid player, for including in other KDE programs.
+ *
+ * @short MIDI/Karaoke player KPart component
  * @author Pedro Lopez-Cabanillas <plcl@users.sf.net>
  * @version 0.1
+ * @see http://api.kde.org/4.x-api/kdelibs-apidocs/interfaces/kmediaplayer/
  */
-class KMidPart : public KMediaPlayer::Player
+class KMIDPART_EXPORT KMidPart : public KMediaPlayer::Player
 {
     Q_OBJECT
     Q_PROPERTY(bool autoStart READ autoStart WRITE setAutoStart)
@@ -50,61 +63,294 @@
      * Constructor for the KMediaPlayer/Engine component
      */
     KMidPart(QObject *parent);
+
     /**
      * Constructor for the KMediaPlayer/Player component
      */
     KMidPart(QWidget *parentWidget,QObject *parent, const QVariantList&);
+
     /**
      * Destructor
      */
     virtual ~KMidPart();
 
+    /**
+     * Returns the View component
+     *
+     * @return a KMediaPlayer::View pointer or 0 if there is no view.
+     * @see KMediaPlayer::Player::view()
+     */
     virtual KMediaPlayer::View* view ();
+
+    /**
+     * Returns whether the current track honors seek requests.
+     * Always true for MIDI files.
+     *
+     * @return true when a MIDI/karaoke file is loaded.
+     * @see KMediaPlayer::Player::isSeekable()
+     */
     virtual bool isSeekable (void) const;
+
+    /**
+     * Returns the current playback position in the track. Like the other
+     * methods in the component, the time unit is ticks (musical time).
+     *
+     * @return the time position in ticks
+     * @see KMediaPlayer::Player::position()
+     */
     virtual qlonglong position (void) const;
+
+    /**
+     * Returns whether the current track has a length.
+     * Always true for MIDI files.
+     *
+     * @return true when a MIDI/karaoke file is loaded.
+     * @see KMediaPlayer::Player::hasLength()
+     */
     virtual bool hasLength (void) const;
+
+    /**
+     * @see KMediaPlayer::Player::length()
+     */
     virtual qlonglong length (void) const;
-    virtual void seek (qlonglong);
 
+    /**
+     * Like the other methods in the component, the time unit is ticks (musical time).
+     *
+     * @param ticks time in ticks
+     * @see KMediaPlayer::Player::seek()
+     */
+    virtual void seek (qlonglong ticks);
+
+    /**
+     * Returns a KAboutData instance pointer for this component.
+     */
     static KAboutData *createAboutData();
 
+    /**
+     * Returns if the tracks should automatically start playing once loaded.
+     */
     bool autoStart();
+
+    /**
+     * Returns the MIDI port name connected to the MIDI OUT of this component
+     */
     QString midiConnection();
+
+    /**
+     * Returns the meta-data extracted from the loaded MIDI file.
+     *
+     * The key argument may be one of the following strings:
+     * SMF_TEXT (arbitrary texts)
+     * SMF_COPYRIGHT (copyright strings)
+     * SMF_TRACKNAMES (track names)
+     * SMF_INSTRUMENTNAMES (instrument names)
+     * SMF_LYRICS (lyrics)
+     * SMF_MARKERS (markers)
+     * SMF_CUES (cue points)
+     *
+     * If the track is a Karaoke file (usually with ".kar" extension) there may
+     * be more keys available: KAR_FILETYPE, KAR_VERSION, KAR_INFORMATION,
+     * KAR_LANGUAGE, KAR_TITLES, and KAR_WARNINGS.
+     */
     QStringList metaData(const QString& key);
+
+    /**
+     * Returns the tempo (speed) factor between 0.5 and 2.0
+     */
     double tempoFactor();
+
+    /**
+     * Returns the volume factor, between 0.0 and 2.0
+     */
     double volumeFactor();
+
+    /**
+     * Returns the transpose amount in semitones, between -12 and +12
+     */
     int transpose();
+
+    /**
+     * Returns the muted state for the specified MIDI channel
+     * @param channel a MIDI channel (0 to 15)
+     */
     bool isMuted(int channel);
 
 public slots:
+    /**
+     * Pauses the playback
+     */
     virtual void pause (void);
+
+    /**
+     * Starts the playback
+     */
     virtual void play (void);
+
+    /**
+     * Stops the playback
+     */
     virtual void stop (void);
 
+    /**
+     * Sets the auto-start feature (enabled by default)
+     *
+     * @param start true to enable or false to disable the auto-start
+     */
     void setAutoStart(bool start);
+
+    /**
+     * Connects the MIDI OUT port to the specified port name
+     *
+     * @param conn MIDI port name for the MIDI OUT connection
+     */
     void setMidiConnection(const QString conn);
+
+    /**
+     * Sets the tempo (speed) factor
+     *
+     * @param f tempo (speed) factor between 0.5 and 2.0
+     */
     void setTempoFactor(double f);
+
+    /**
+     * Sets the volume factor
+     *
+     * @param f volume factor between 0.0 and 2.0
+     */
     void setVolumeFactor(double f);
+
+    /**
+     * Sets the transpose amount in semitones
+     *
+     * @param t transpose amount in semitones, between -12 and +12
+     */
     void setTranspose(int t);
+
+    /**
+     * Sets the mute state for the specified MIDI channel
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param muted state
+     */
     void setMuted(int channel, bool muted);
+
+    /**
+     * Reloads the current track, preserving the time position in ticks
+     */
     void reload();
 
 signals:
-    void tempoEvent(qreal);
-    void timeSignatureEvent(int,int);
-    void midiTextEvent(int, const QString&);
-    void midiNoteOnEvent(int,int,int);
-    void midiNoteOffEvent(int,int,int);
-    void midiControllerEvent(int,int,int);
-    void midiKeyPressureEvent(int,int,int);
-    void midiProgramEvent(int,int);
-    void midiChannelPressureEvent(int,int);
-    void midiPitchBendEvent(int,int);
-    void beat(int,int,int);
-    void tick(qint64);
+    /**
+     * Emitted when a tempo change is played
+     *
+     * @param changed tempo, including the applied tempo factor
+     */
+    void tempoEvent(qreal tempo);
+
+    /**
+     * Emitted when a time signature (rhythm specification) is played
+     *
+     * @param num rhythm numerator
+     * @param den rhythm denominator
+     */
+    void timeSignatureEvent(int num, int den);
+
+    /**
+     * Emitted when a text event (lyric or otherwise) is played
+     *
+     * @param type SMF metadata type (1=text, 5=lyric, ...)
+     * @param text event data
+     */
+    void midiTextEvent(int type, const QString& text);
+
+    /**
+     * Emitted when a MIDI note on event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     *
+     */
+    void midiNoteOnEvent(int channel, int note, int velocity);
+
+    /**
+     * Emitted when a MIDI note off event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param note MIDI note
+     * @param velocity MIDI velocity
+     */
+    void midiNoteOffEvent(int channel, int note, int velocity);
+
+    /**
+     * Emitted when a MIDI control change event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param ctl MIDI controller
+     * @param value controller value
+     */
+    void midiControllerEvent(int channel, int ctl, int value);
+
+    /**
+     * Emitted when a MIDI polyphonic pressure event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param note MIDI note
+     * @param value pressure value
+     */
+    void midiKeyPressureEvent(int channel, int note, int value);
+
+    /**
+     * Emitted when a MIDI program event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param value program value
+     */
+    void midiProgramEvent(int channel, int program);
+
+    /**
+     * Emitted when a MIDI channel pressure event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param value pressure value
+     */
+    void midiChannelPressureEvent(int channel, int value);
+
+    /**
+     * Emitted when a MIDI pitch bend event is played
+     *
+     * @param channel MIDI channel, between 0 and 15
+     * @param value pitch bender value
+     */
+    void midiPitchBendEvent(int channel, int value);
+
+    /**
+     * Emitted when each beat gets played
+     *
+     * @param bar measure (bar) number
+     * @param beat beat number
+     * @param max number of beats for the current measure
+     */
+    void beat(int bar, int beat, int max);
+
+    /**
+     * This signal gets emitted every tickInterval.
+     *
+     * @param time The position of the media file in ticks.
+     */
+    void tick(qint64 time);
+
+    /**
+     * Emitted when the track has finished playback.
+     */
     void finished();
-    void sourceChanged(QString);
 
+    /**
+     * Emitted when the player loads a new track
+     *
+     * @param source the new loaded track
+     */
+    void sourceChanged(QString source);
+
 private slots:
     void slotLoaded(Backend *backend, const QString& library, const QString& name);
     void slotUpdateState(State, State);
--- trunk/extragear/multimedia/kmid/src/kmid_partview.h #1153052:1153053
@@ -22,30 +22,77 @@
 
 #include <KMediaPlayer/View>
 
-class KMidPartView : public KMediaPlayer::View {
+#ifndef KMIDPART_EXPORT
+# if defined(kmid_part_EXPORTS)
+#  define KMIDPART_EXPORT KDE_EXPORT
+# else
+#  define KMIDPART_EXPORT KDE_IMPORT
+# endif
+#endif
+
+/**
+ * KMidPartView is an implementation of the KMediaPlayer::View interface for
+ * the KMidPart (MIDI/Karaoke player) component.
+ *
+ * KMediaPlayer::View defines four controls for the user interface:
+ * the buttons play, pause and stop, and a seeker control. This class implements
+ * the play/stop buttons as a single control, and the seeker as a slider. In
+ * addition to them, there are also several controls hidden by default:
+ * a pause button, two dial controls for volume and pitch transpose, and a
+ * speed slider with a speed reset button. All of them can be shown or hidden
+ * using the methods from KMediaPlayer::View with arguments calculated combining
+ * values from the ExtraControl and Button enumerations.
+ *
+ * @see http://api.kde.org/4.x-api/kdelibs-apidocs/interfaces/kmediaplayer/
+ */
+class KMIDPART_EXPORT KMidPartView : public KMediaPlayer::View {
     Q_OBJECT
 public:
+    /**
+     * Constructor
+     * @param parent a parent widget
+     */
     KMidPartView(QWidget *parent);
+
+    /**
+     * Destructor
+     */
     virtual ~KMidPartView();
 
-    /** Controls that can appear in the UI
-     * (initially hidden) in addition to Button ones
-     * see @Button
+    /**
+     * Controls that may appear in the UI (initially hidden). These values can
+     * be used in addition to the Button enumeration.
+     *
+     * see @KMediaPlayer::View::Button
      */
     enum ExtraControl
     {
-        /** Volume factor knob */
+        /** Volume factor control */
         Volume = 16,
-        /** Transpose knob */
+        /** Transpose control */
         Transpose = 32,
-        /** Tempo factor */
+        /** Tempo (speed) factor */
         Tempo = 64
     };
 
+    /**
+     * Resets the time control range and position
+     * @param totalTime song length in ticks
+     */
     void resetTimePosition(qint64 totalTime);
+
+    /**
+     * Sets the time control position
+     * @param tick song time in ticks
+     */
     void setPosition(qint64 tick);
-    void setPlayingState(bool);
 
+    /**
+     * Changes the UI playback state
+     * @param playing true if playing, false otherwise
+     */
+    void setPlayingState(bool playing);
+
 private slots:
     void slotButtonsChanged(int);
     void slotPlayStop();
@@ -57,14 +104,45 @@
     void slotTempoReset();
 
 signals:
+    /**
+     * Emitted when the play control is activated
+     */
     void play();
+
+    /**
+     * Emitted when the pause control is activated
+     */
     void pause();
+
+    /**
+     * Emitted when the stop control is activated
+     */
     void stop();
-    void seek(int);
-    void volume(double);
-    void transpose(int);
-    void speed(double);
 
+    /**
+     * Emitted when the seeker position is changed
+     * @param pos the new position of the seeker slider
+     */
+    void seek(int pos);
+
+    /**
+     * Emitted when the volume control is activated
+     * @param volfactor volume factor: 0.0=min, 1.0=middle, 2.0=max
+     */
+    void volume(double volfactor);
+
+    /**
+     * Emitted when the transpose control is activated
+     * @param pitch transpose factor: -12=min, 0=middle, +12=max
+     */
+    void transpose(int pitch);
+
+    /**
+     * Emitted when the speed control is activated
+     * @param tempofactor speed factor: 0.5=min, 1.0=middle, 2.0=max
+     */
+    void speed(double tempofactor);
+
 private:
     class ViewPrivate;
     ViewPrivate* d;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic