Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist/
*.aiff

.stack-work
.idea
*.iml
6 changes: 3 additions & 3 deletions HaskellViewer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ build-type: Simple
cabal-version: >=1.8

library
exposed-modules: Displayable, Viewer, Playable
other-modules: AIFF
build-depends: base ==4.6.*, HPDF >=1.4.5, network ==2.4.*, bytestring ==0.10.*
exposed-modules: HaskellViewer.Displayable, HaskellViewer.Viewer, HaskellViewer.Playable
other-modules: HaskellViewer.AIFF
build-depends: base > 4.5 && < 5, HPDF >=1.4.5, network, bytestring
4 changes: 2 additions & 2 deletions AIFF.hs → HaskellViewer/AIFF.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AIFF(
module HaskellViewer.AIFF(
encodeSound
) where

Expand Down Expand Up @@ -75,4 +75,4 @@ encodeSound sampling samples =
common sampling nbSamples <>
sound samples nbSamples
in
toLazyByteString r
toLazyByteString r
2 changes: 1 addition & 1 deletion Displayable.hs → HaskellViewer/Displayable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
By default, any Draw() value can be displayed !

-}
module Displayable(
module HaskellViewer.Displayable(
Displayable(..)
, Rsrc(..)
, DrawingAction(..)
Expand Down
11 changes: 11 additions & 0 deletions HaskellViewer/Playable.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{-# LANGUAGE FlexibleInstances #-}
module HaskellViewer.Playable(
Playable(..)
) where

class Playable a where
sound :: a -> (Double,[Double])

instance Playable (Double,[Double]) where
sound = id

12 changes: 6 additions & 6 deletions Viewer.hs → HaskellViewer/Viewer.hs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{- | Functions used to communicate with the OS X hViewer

-}
module Viewer(
module HaskellViewer.Viewer(
display
, viewerSize
, play
) where

import Graphics.PDF
import Displayable
import Playable
import HaskellViewer.Displayable
import HaskellViewer.Playable

import Network
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.ByteString.Lazy.Builder as B
import GHC.IO.Handle(hFlush,hClose)
import AIFF(encodeSound)
import HaskellViewer.AIFF(encodeSound)

dispCode = L.pack "disp"
playCode = L.pack "play"

-- | Convert a Displayable into a PDF byetstream
getPDFStream :: Displayable a b => Int -> Int -> a -> IO L.ByteString
getPDFStream :: Displayable a b => Int -> Int -> a -> L.ByteString
getPDFStream width height drawingCode = do
let rect = PDFRect 0 0 width height
let (aPdfValue, drawAction) = drawing drawingCode
Expand All @@ -45,7 +45,7 @@ display :: Displayable a b
-> IO ()
display d = do
let (w,h) = viewerSize
stream <- getPDFStream w h d
let stream = getPDFStream w h d
sendStream 9000 (L.append dispCode stream)

play :: Playable a
Expand Down
12 changes: 0 additions & 12 deletions Playable.hs

This file was deleted.

10 changes: 10 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

resolver: lts-6.4

packages:
- '.'
extra-deps: []

flags: {}

extra-package-dbs: []