John Paul Adrian Glaubitz wrote:
On Wed, Jul 31, 2013 at 08:32:33AM -0700, Howard Chu wrote:John Paul Adrian Glaubitz wrote:Hello Howard, On 07/31/2013 04:09 PM, Howard Chu wrote:I only use MDs for live recordings, and I never title the tracks. I just go by the recording date to remind me what the tracks contain. It always frustrated me that QHiMDTransfer didn't display this info, so I've written this patch to add it. Please consider merging this, thanks.Thanks a lot for your contribution! We'll review your patch within the next few days and apply it once we're happy with it.Sounds good. It also occurs to me, it would be nice to set the timestamp on the transferred files as well. If you're interested I'll write a patch for this too.Sure, go ahead ;).
Worksforme ;)
We're all currently a bit low on time, so there isn't much upstream development at the moment even though we have still some things on the TODO list and we already know how to implement most of the things (most of the things behind NetMD/HiMD is already documented in the wiki). In any case, thanks a lot for your contributions! Cheers, Adrian
-- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/
>From 9d99649303dd655200e98518334e12377f3236c9 Mon Sep 17 00:00:00 2001 From: Howard Chu <hyc@symas.com> Date: Wed, 31 Jul 2013 09:26:12 -0700 Subject: [PATCH] Set datestamp of uploaded tracks --- qhimdtransfer/qhimdmainwindow.cpp | 39 +++++++++++++++++++++++++++++++++++++ qhimdtransfer/qhimdmainwindow.h | 1 + 2 files changed, 40 insertions(+) diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp index e2675d9..5e1bf87 100644 --- a/qhimdtransfer/qhimdmainwindow.cpp +++ b/qhimdtransfer/qhimdmainwindow.cpp @@ -7,6 +7,35 @@ #include <QtCore/QDebug> +#ifndef Q_OS_WIN +#include <sys/time.h> +#endif + +void QHiMDMainWindow::setstamp(const QHiMDTrack & trk, QFile & f) +{ + QDateTime dt = trk.recdate(); + f.flush(); +#ifdef Q_OS_WIN + SYSTEMTIME st; + FILETIME ft; + QDate d = dt.date(); + QTime t = dt.time(); + st.wYear = d.year(); + st.wMonth = d.month(); + st.wDay = d.day(); + st.wHour = t.hour(); + st.wMinute = t.minute(); + st.wSecond = t.second(); + st.wMilliseconds = t.msec(); + if (SystemTimeToFileTime(&st, &ft)) + SetFileTime(f.handle(), &ft, NULL, &ft); +#else + struct timeval tv[2]; + tv[0].tv_usec = tv[1].tv_usec = 0; + tv[0].tv_sec = tv[1].tv_sec = dt.toTime_t(); + futimes(f.handle(), tv); +#endif +} QString QHiMDMainWindow::dumpmp3(const QHiMDTrack & trk, QString file) { @@ -44,6 +73,8 @@ QString QHiMDMainWindow::dumpmp3(const QHiMDTrack & trk, QString file) } if(status.status != HIMD_STATUS_AUDIO_EOF) errmsg = tr("Error reading audio data: ") + status.statusmsg; + else + setstamp(trk, f); clean: f.close(); @@ -113,6 +144,8 @@ QString QHiMDMainWindow::dumpoma(const QHiMDTrack & track, QString file) } if(status.status != HIMD_STATUS_AUDIO_EOF) errmsg = QString("Error reading audio data: ") + status.statusmsg; + else + setstamp(track, f); clean: f.close(); @@ -142,6 +175,9 @@ QString QHiMDMainWindow::dumppcm(const QHiMDTrack & track, QString file) signal_out.precision = 16; signal_out.rate = 44100; + if(!f.open(QIODevice::ReadWrite)) + return tr("Error opening file for WAV output"); + if(!(out = sox_open_write(file.toUtf8(), &signal_out, NULL, NULL, NULL, NULL))) return tr("Error opening file for WAV output"); @@ -181,8 +217,11 @@ QString QHiMDMainWindow::dumppcm(const QHiMDTrack & track, QString file) } if(status.status != HIMD_STATUS_AUDIO_EOF) errmsg = QString("Error reading audio data: ") + status.statusmsg; + else + setstamp(track, f); clean: + f.close(); sox_close(out); himd_nonmp3stream_close(&str); diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h index 85be8ae..bc97af6 100644 --- a/qhimdtransfer/qhimdmainwindow.h +++ b/qhimdtransfer/qhimdmainwindow.h @@ -53,6 +53,7 @@ private: bool autodetect_init(); void open_himd_at(const QString & path); void upload_to(const QString & path); + void setstamp(const QHiMDTrack & trk, QFile &f); private slots: void on_action_Connect_triggered(); -- 1.7.9.5