Browse Source

Water cleanup

tags/v1.9.9
falkTX 6 years ago
parent
commit
7be0066c07
15 changed files with 24 additions and 396 deletions
  1. +1
    -1
      source/modules/water/README
  2. +1
    -6
      source/modules/water/files/File.cpp
  3. +1
    -16
      source/modules/water/files/File.h
  4. +0
    -144
      source/modules/water/processors/AudioPlayHead.h
  5. +2
    -44
      source/modules/water/processors/AudioProcessor.cpp
  6. +1
    -38
      source/modules/water/processors/AudioProcessor.h
  7. +3
    -18
      source/modules/water/streams/FileInputSource.cpp
  8. +4
    -11
      source/modules/water/streams/FileInputSource.h
  9. +0
    -76
      source/modules/water/streams/InputSource.h
  10. +1
    -2
      source/modules/water/streams/InputStream.cpp
  11. +1
    -22
      source/modules/water/text/String.cpp
  12. +1
    -10
      source/modules/water/text/String.h
  13. +2
    -2
      source/modules/water/water.h
  14. +2
    -2
      source/modules/water/xml/XmlDocument.cpp
  15. +4
    -4
      source/modules/water/xml/XmlDocument.h

+ 1
- 1
source/modules/water/README View File

@@ -5,4 +5,4 @@ Using Juce version 4 means we can use its GPL v2+ license.
Starting from version 5, Juce uses GPLv3.

Do not use this library in your own code!
There are no plans to make it generic library or any support for its use outside of Carla.
There are no plans to make it a generic library or give any support for its use outside of Carla.

+ 1
- 6
source/modules/water/files/File.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -398,11 +398,6 @@ bool File::isAChildOf (const File& potentialParent) const
return getParentDirectory().isAChildOf (potentialParent);
}
#if 0
int File::hashCode() const { return fullPath.hashCode(); }
int64 File::hashCode64() const { return fullPath.hashCode64(); }
#endif
//==============================================================================
bool File::isAbsolutePath (StringRef path)
{


+ 1
- 16
source/modules/water/files/File.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -221,21 +221,6 @@ public:
*/
String getFileNameWithoutExtension() const;
//==============================================================================
/** Returns a 32-bit hash-code that identifies this file.
This is based on the filename. Obviously it's possible, although unlikely, that
two files will have the same hash-code.
*/
int hashCode() const;
/** Returns a 64-bit hash-code that identifies this file.
This is based on the filename. Obviously it's possible, although unlikely, that
two files will have the same hash-code.
*/
int64 hashCode64() const;
//==============================================================================
/** Returns a file that represents a relative (or absolute) sub-path of the current one.


+ 0
- 144
source/modules/water/processors/AudioPlayHead.h View File

@@ -1,144 +0,0 @@
/*
==============================================================================
This file is part of the Water library.
Copyright (c) 2015 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the GNU
General Public License as published by the Free Software Foundation;
either version 2 of the License, or 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.
For a full copy of the GNU General Public License see the doc/GPL.txt file.
==============================================================================
*/
#ifndef WATER_AUDIOPLAYHEAD_H_INCLUDED
#define WATER_AUDIOPLAYHEAD_H_INCLUDED
#include "../water.h"
namespace water {
//==============================================================================
/**
A subclass of AudioPlayHead can supply information about the position and
status of a moving play head during audio playback.
One of these can be supplied to an AudioProcessor object so that it can find
out about the position of the audio that it is rendering.
@see AudioProcessor::setPlayHead, AudioProcessor::getPlayHead
*/
class AudioPlayHead
{
protected:
//==============================================================================
AudioPlayHead() {}
public:
virtual ~AudioPlayHead() {}
//==============================================================================
/** Frame rate types. */
enum FrameRateType
{
fps24 = 0,
fps25 = 1,
fps2997 = 2,
fps30 = 3,
fps2997drop = 4,
fps30drop = 5,
fpsUnknown = 99
};
//==============================================================================
/** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
*/
struct CurrentPositionInfo
{
/** The tempo in BPM */
double bpm;
/** Time signature numerator, e.g. the 3 of a 3/4 time sig */
int timeSigNumerator;
/** Time signature denominator, e.g. the 4 of a 3/4 time sig */
int timeSigDenominator;
/** The current play position, in samples from the start of the edit. */
int64 timeInSamples;
/** The current play position, in seconds from the start of the edit. */
double timeInSeconds;
/** For timecode, the position of the start of the edit, in seconds from 00:00:00:00. */
double editOriginTime;
/** The current play position, in pulses-per-quarter-note. */
double ppqPosition;
/** The position of the start of the last bar, in pulses-per-quarter-note.
This is the time from the start of the edit to the start of the current
bar, in ppq units.
Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
it's not available, the value will be 0.
*/
double ppqPositionOfLastBarStart;
/** The video frame rate, if applicable. */
FrameRateType frameRate;
/** True if the transport is currently playing. */
bool isPlaying;
/** True if the transport is currently recording.
(When isRecording is true, then isPlaying will also be true).
*/
bool isRecording;
/** The current cycle start position in pulses-per-quarter-note.
Note that not all hosts or plugin formats may provide this value.
@see isLooping
*/
double ppqLoopStart;
/** The current cycle end position in pulses-per-quarter-note.
Note that not all hosts or plugin formats may provide this value.
@see isLooping
*/
double ppqLoopEnd;
/** True if the transport is currently looping. */
bool isLooping;
//==============================================================================
bool operator== (const CurrentPositionInfo& other) const noexcept;
bool operator!= (const CurrentPositionInfo& other) const noexcept;
void resetToDefault();
};
//==============================================================================
/** Fills-in the given structure with details about the transport's
position at the start of the current processing block. If this method returns
false then the current play head position is not available and the given
structure will be undefined.
You can ONLY call this from your processBlock() method! Calling it at other
times will produce undefined behaviour, as the host may not have any context
in which a time would make sense, and some hosts will almost certainly have
multithreading issues if it's not called on the audio thread.
*/
virtual bool getCurrentPosition (CurrentPositionInfo& result) = 0;
};
}
#endif // WATER_AUDIOPLAYHEAD_H_INCLUDED

+ 2
- 44
source/modules/water/processors/AudioProcessor.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2015 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the GNU
General Public License as published by the Free Software Foundation;
@@ -27,7 +27,6 @@ AudioProcessor::AudioProcessor()
cachedTotalIns = 0;
cachedTotalOuts = 0;
// playHead = nullptr;
currentSampleRate = 0;
blockSize = 0;
latencySamples = 0;
@@ -41,11 +40,6 @@ AudioProcessor::~AudioProcessor()
}
//==============================================================================
// void AudioProcessor::setPlayHead (AudioPlayHead* const newPlayHead)
// {
// playHead = newPlayHead;
// }
void AudioProcessor::setPlayConfigDetails (const int newNumIns,
const int newNumOuts,
const double newSampleRate,
@@ -82,46 +76,10 @@ void AudioProcessor::suspendProcessing (const bool shouldBeSuspended)
void AudioProcessor::reset() {}
void AudioProcessor::processBypassed (AudioSampleBuffer& buffer, MidiBuffer&)
void AudioProcessor::processBlockBypassed (AudioSampleBuffer& buffer, MidiBuffer&)
{
for (int ch = getTotalNumInputChannels(); ch < getTotalNumOutputChannels(); ++ch)
buffer.clear (ch, 0, buffer.getNumSamples());
}
void AudioProcessor::processBlockBypassed (AudioSampleBuffer& buffer, MidiBuffer& midi) { processBypassed (buffer, midi); }
#if 0
//==============================================================================
bool AudioPlayHead::CurrentPositionInfo::operator== (const CurrentPositionInfo& other) const noexcept
{
return timeInSamples == other.timeInSamples
&& ppqPosition == other.ppqPosition
&& editOriginTime == other.editOriginTime
&& ppqPositionOfLastBarStart == other.ppqPositionOfLastBarStart
&& frameRate == other.frameRate
&& isPlaying == other.isPlaying
&& isRecording == other.isRecording
&& bpm == other.bpm
&& timeSigNumerator == other.timeSigNumerator
&& timeSigDenominator == other.timeSigDenominator
&& ppqLoopStart == other.ppqLoopStart
&& ppqLoopEnd == other.ppqLoopEnd
&& isLooping == other.isLooping;
}
bool AudioPlayHead::CurrentPositionInfo::operator!= (const CurrentPositionInfo& other) const noexcept
{
return ! operator== (other);
}
void AudioPlayHead::CurrentPositionInfo::resetToDefault()
{
zerostruct (*this);
timeSigNumerator = 4;
timeSigDenominator = 4;
bpm = 120;
}
#endif
}

+ 1
- 38
source/modules/water/processors/AudioProcessor.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2015 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the GNU
General Public License as published by the Free Software Foundation;
@@ -164,26 +164,6 @@ public:
virtual void processBlockBypassed (AudioSampleBuffer& buffer,
MidiBuffer& midiMessages);
#if 0
//==============================================================================
/** Returns the current AudioPlayHead object that should be used to find
out the state and position of the playhead.
You can ONLY call this from your processBlock() method! Calling it at other
times will produce undefined behaviour, as the host may not have any context
in which a time would make sense, and some hosts will almost certainly have
multithreading issues if it's not called on the audio thread.
The AudioPlayHead object that is returned can be used to get the details about
the time of the start of the block currently being processed. But do not
store this pointer or use it outside of the current audio callback, because
the host may delete or re-use it.
If the host can't or won't provide any time info, this will return nullptr.
*/
AudioPlayHead* getPlayHead() const noexcept { return playHead; }
#endif
//==============================================================================
/** Returns the total number of input channels.
@@ -338,15 +318,6 @@ public:
*/
virtual void setNonRealtime (bool isNonRealtime) noexcept;
#if 0
//==============================================================================
/** Tells the processor to use this playhead object.
The processor will not take ownership of the object, so the caller must delete it when
it is no longer being used.
*/
virtual void setPlayHead (AudioPlayHead* newPlayHead);
#endif
//==============================================================================
/** This is called by the processor to specify its details before being played. Use this
version of the function if you are not interested in any sidechain and/or aux buses
@@ -362,12 +333,6 @@ public:
void setRateAndBufferSizeDetails (double sampleRate, int blockSize) noexcept;
private:
#if 0
//==============================================================================
/** @internal */
AudioPlayHead* playHead;
#endif
//==============================================================================
double currentSampleRate;
int blockSize, latencySamples;
@@ -379,8 +344,6 @@ private:
int cachedTotalIns, cachedTotalOuts;
void processBypassed (AudioSampleBuffer&, MidiBuffer&);
CARLA_DECLARE_NON_COPY_CLASS (AudioProcessor)
};


+ 3
- 18
source/modules/water/streams/FileInputSource.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -24,14 +24,11 @@
*/
#include "FileInputSource.h"
#include "../files/FileInputStream.h"
namespace water {
FileInputSource::FileInputSource (const File& f, bool useFileTimeInHash)
: file (f), useFileTimeInHashGeneration (useFileTimeInHash)
{
}
FileInputSource::FileInputSource (const File& f)
: file (f) {}
FileInputSource::~FileInputSource()
{
@@ -47,16 +44,4 @@ InputStream* FileInputSource::createInputStreamFor (const String& relatedItemPat
return file.getSiblingFile (relatedItemPath).createInputStream();
}
#if 0
int64 FileInputSource::hashCode() const
{
int64 h = file.hashCode();
if (useFileTimeInHashGeneration)
h ^= file.getLastModificationTime().toMilliseconds();
return h;
}
#endif
}

+ 4
- 11
source/modules/water/streams/FileInputSource.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -26,7 +26,6 @@
#ifndef WATER_FILEINPUTSOURCE_H_INCLUDED
#define WATER_FILEINPUTSOURCE_H_INCLUDED
#include "InputSource.h"
#include "../files/File.h"
namespace water {
@@ -37,28 +36,22 @@ namespace water {
@see InputSource
*/
class FileInputSource : public InputSource
class FileInputSource
{
public:
//==============================================================================
/** Creates a FileInputSource for a file.
If the useFileTimeInHashGeneration parameter is true, then this object's
hashCode() method will incorporate the file time into its hash code; if
false, only the file name will be used for the hash.
*/
FileInputSource (const File& file, bool useFileTimeInHashGeneration = false);
/** Creates a FileInputSource for a file. */
FileInputSource (const File& file);
/** Destructor. */
~FileInputSource();
InputStream* createInputStream();
InputStream* createInputStreamFor (const String& relatedItemPath);
int64 hashCode() const;
private:
//==============================================================================
const File file;
bool useFileTimeInHashGeneration;
CARLA_DECLARE_NON_COPY_CLASS (FileInputSource)
};


+ 0
- 76
source/modules/water/streams/InputSource.h View File

@@ -1,76 +0,0 @@
/*
==============================================================================
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
==============================================================================
*/
#ifndef WATER_INPUTSOURCE_H_INCLUDED
#define WATER_INPUTSOURCE_H_INCLUDED
#include "../water.h"
namespace water {
//==============================================================================
/**
A lightweight object that can create a stream to read some kind of resource.
This may be used to refer to a file, or some other kind of source, allowing a
caller to create an input stream that can read from it when required.
@see FileInputSource
*/
class InputSource
{
public:
//==============================================================================
InputSource() noexcept {}
/** Destructor. */
virtual ~InputSource() {}
//==============================================================================
/** Returns a new InputStream to read this item.
@returns an inputstream that the caller will delete, or nullptr if
the filename isn't found.
*/
virtual InputStream* createInputStream() = 0;
/** Returns a new InputStream to read an item, relative.
@param relatedItemPath the relative pathname of the resource that is required
@returns an inputstream that the caller will delete, or nullptr if
the item isn't found.
*/
virtual InputStream* createInputStreamFor (const String& relatedItemPath) = 0;
#if 0
/** Returns a hash code that uniquely represents this item.
*/
virtual int64 hashCode() const = 0;
#endif
};
}
#endif // WATER_INPUTSOURCE_H_INCLUDED

+ 1
- 2
source/modules/water/streams/InputStream.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -23,7 +23,6 @@
==============================================================================
*/
#include "InputSource.h"
#include "InputStream.h"
#include "../memory/ByteOrder.h"
#include "../streams/MemoryOutputStream.h"


+ 1
- 22
source/modules/water/text/String.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -486,27 +486,6 @@ water_uchar String::operator[] (int index) const noexcept
return text [index];
}
template <typename Type>
struct HashGenerator
{
template <typename CharPointer>
static Type calculate (CharPointer t) noexcept
{
Type result = Type();
while (! t.isEmpty())
result = ((Type) multiplier) * result + (Type) t.getAndAdvance();
return result;
}
enum { multiplier = sizeof (Type) > 4 ? 101 : 31 };
};
int String::hashCode() const noexcept { return HashGenerator<int> ::calculate (text); }
int64 String::hashCode64() const noexcept { return HashGenerator<int64> ::calculate (text); }
size_t String::hash() const noexcept { return HashGenerator<size_t> ::calculate (text); }
//==============================================================================
bool operator== (const String& s1, const String& s2) noexcept { return s1.compare (s2) == 0; }
bool operator!= (const String& s1, const String& s2) noexcept { return s1.compare (s2) != 0; }


+ 1
- 10
source/modules/water/text/String.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -120,15 +120,6 @@ public:
typedef CharPointer_UTF8 CharPointerType;
//==============================================================================
/** Generates a probably-unique 32-bit hashcode from this string. */
int hashCode() const noexcept;
/** Generates a probably-unique 64-bit hashcode from this string. */
int64 hashCode64() const noexcept;
/** Generates a probably-unique hashcode from this string. */
size_t hash() const noexcept;
/** Returns the number of characters in the string. */
int length() const noexcept;


+ 2
- 2
source/modules/water/water.h View File

@@ -1,7 +1,7 @@
/*
* Cross-platform C++ library for Carla, based on Juce v4
* Copyright (C) 2015 ROLI Ltd.
* Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -69,9 +69,9 @@ namespace water
class AudioProcessor;
class File;
class FileInputStream;
class FileInputSource;
class FileOutputStream;
class Identifier;
class InputSource;
class InputStream;
class MidiBuffer;
class MidiMessage;


+ 2
- 2
source/modules/water/xml/XmlDocument.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -68,7 +68,7 @@ XmlElement* XmlDocument::parse (const String& xmlData)
return doc.getDocumentElement();
}
void XmlDocument::setInputSource (InputSource* const newSource) noexcept
void XmlDocument::setInputSource (FileInputSource* const newSource) noexcept
{
inputSource = newSource;
}


+ 4
- 4
source/modules/water/xml/XmlDocument.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -122,9 +122,9 @@ public:
The object that is passed-in will be deleted automatically when no longer needed.
@see InputSource
@see FileInputSource
*/
void setInputSource (InputSource* newSource) noexcept;
void setInputSource (FileInputSource* newSource) noexcept;
/** Sets a flag to change the treatment of empty text elements.
@@ -158,7 +158,7 @@ private:
String lastError, dtdText;
StringArray tokenisedDTD;
bool needToLoadDTD, ignoreEmptyTextElements;
ScopedPointer<InputSource> inputSource;
ScopedPointer<FileInputSource> inputSource;
XmlElement* parseDocumentElement (String::CharPointerType, bool outer);
void setLastError (const String&, bool carryOn);


Loading…
Cancel
Save