Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Multidevice ASIO output plugin for WinAMP

, 13 Feb 2009 CDDL
A tiny WinAMP output DLL that uses a C++ replacement of the official ASIO SDK that supports multiple ASIO devices.
#pragma once

#include "buffers.hpp"
#include "WAOutModule.hpp"

#include "ASIO SDK/common/asio.h"


namespace WinAMP
{

namespace OutModule
{

////////////////////////////////////////////////////////////////////////////////
//
//  Writer
//  ------
//
//  Wraps a buffer dedicated for a single ASIO output sample type as well as
// additional data and functionality required for WinAMP interaction (mainly the
// the write callback used for transforming the input data into the output
// format).
//
////////////////////////////////////////////////////////////////////////////////

class Writer
{
public:
    MultiChannelBuffer               & buffer                   ()                                                    { return buffer_                                 ; }
    MultiChannelBuffer         const & buffer                   ()                                              const { return const_cast<Writer &>( *this ).buffer()  ; }
    WAOutModule::WriteCallback         callback                 ()                                              const { assert( writeCallback_ ); return writeCallback_; }
    size_t                             outputBytesPerSample     ()                                              const { return outputBytesPerSample_                   ; }
    ASIOSampleType                     outputSampleType         ()                                              const { return outputSampleType_                       ; }
    int                                write                    ( char * const buffer, int const bufferLength ) const { return callback()( buffer, bufferLength )      ; }
    int                                writtenTimeInMilliseconds()                                              const;

    bool setUpForIOParameters( int inputBitsPerSecond, size_t outputSampleRate );

    typedef int (Writer::*unspecified_bool_type)() const;
    operator unspecified_bool_type() const { return writeCallback_ ? &Writer::writtenTimeInMilliseconds : 0; }

private: // WriterForASIOSampleType private interface.
    template <ASIOSampleType> friend class WriterForASIOSampleType;
    Writer( ASIOSampleType, size_t outputBytesPerSample );

private: // Non copyable.
    Writer        ( Writer const & );
    void operator=( Writer const & );

private:
    MultiChannelBuffer               buffer_              ;
    WAOutModule::WriteCallback       writeCallback_       ;
    size_t                           outputSampleRate_    ;
    ASIOSampleType             const outputSampleType_    ;
    size_t                     const outputBytesPerSample_;
};


Writer       & getOutputSampleTypeWriter( ASIOSampleType                     );
Writer const & getReadersWriter         ( MultiChannelBuffer::Reader const & );


}   // namespace OutModule

}   // namespace WinAMP

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Domagoj Šarić
Software Developer Little Endian Ltd.
Croatia Croatia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 13 Feb 2009
Article Copyright 2009 by Domagoj Šarić
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid